(custom-resources): CustomResourceProvider should destroy log group when stack deleted
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 74
Description
Describe the feature
Delete Log Groups created by auto-created a CustomResourceProvider when stack is destroyed. These are sometimes an "implementation detail" of constructs like s3.Bucket, so a CDK user may not be aware they need to clean them up.
Use Case
My CDK created an s3.Bucket with autoDeleteObjects: true, and when I destroy the stack, I noticed there was still a CloudWatch Log Group not cleaned up.
[/aws/lambda/XXXXXXXXXXXStack-CustomS3AutoDeleteObjectsCustomRe-xxxxxxxxxxxx
This appears to be a result of the auto-created Log Group for the CustomResourceProvider Lambda. This leaves cruft in the AWS account, which the user didn't intent to create.
Proposed Solution
after the CustomResourceProvider 'AWS::Lambda::Function' is created, also create the "AWS::Logs::LogGroup" and set RemovalPolicy to destroy
Other Information
No response
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
CDK version used
2.88.0 (build 5d497f9)
Environment details (OS name and version, etc.)
macOS 12.6.6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/aws-cdk-lib/core/lib/custom-resource-provider/custom-resource-provider.ts around the AWS::Lambda::Function creation referenced in the issue. Trace how the CustomResourceProvider is synthesized, then verify that its AWS::Logs::LogGroup is removed when the stack is destroyed. The issue does not name a test file, so inspect nearby provider tests before running the relevant test suite.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100