(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:
- Created 3 years ago
- Reactions:7
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
⚠️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.