question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(lambda): Unnecessary custom resource for Lambda log retention?

See original GitHub issue

❓ General Issue

Custom CloudFormation resource is created to set Lambda Log Retention

When added logRetention to a Lambda, a custom resource is created.

        return Function.Builder.create(this, id)
                .code(Code.fromAsset("qrcode-service-lambdas/qrcode-processor/target/qrcode-processor.zip"))
                .handler("io.quarkus.amazon.lambda.runtime.QuarkusStreamHandler::handleRequest")
                .runtime(Runtime.JAVA_11)
                .logRetention(RetentionDays.ONE_WEEK)
                .build();

It looks like this is a workaround for a lerna issue in CDK itself? https://github.com/aws/aws-cdk/blob/3727c715e17b5fb41a8a7a6f012d5a1936bac347/packages/%40aws-cdk/aws-logs/lib/log-retention.ts#L82-L82

Shouldn’t there be a better way/workaround instead of creating unnecessary resources like this in AWS? It’s very confusing to explain to people who are less familiar in AWS why this is needed. With AWS SAM/Serverless Framework this is not required.

Environment

  • CDK CLI Version: 1.75
  • Language (Version): Java (8)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jogoldcommented, Dec 7, 2020

Even with the core L2 construct it still would be a custom resource?

Yes because a log group is created implicitly when a Lambda function starts to log. So we need a custom resource to cover all the edge cases as discussed in #248 and #667.

0reactions
github-actions[bot]commented, Dec 8, 2020

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

class LogRetention (construct) · AWS CDK
Creates a custom resource to control the retention policy of a CloudWatch Logs log group. The log group is created if it doesn't...
Read more >
Configure Lambda Log Retention in AWS CDK | bobbyhadz
By setting the logRetention prop for our lambda function, we created a custom CloudFormation resource.
Read more >
How to manage Lambda log groups with Terraform
First, the log group created by Lambda does not set any expiration to the log messages. This is a good default, but since...
Read more >
Stack deletion deletes log group but re-creates it on lambda ...
Hello, I have a cloudformation template which defines a lambda, which is invoked by a custom resource. The cloud formation creates a log...
Read more >
Lambda Log Retention - Serverless Rules
By default, CloudWatch log groups created by Lambda functions have an unlimited retention time. For cost optimization purposes, you should set a retention...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found