-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(custom-resources): CustomResourceProvider should destroy log group when stack deleted #26553
Comments
Can you use |
Since I don't create the custom resource, but the "Metadata": {
"aws:cdk:path": "MyStack/Custom::S3AutoDeleteObjectsCustomResourceProvider/Handler", |
You can view the construct path in Alternative to this, you can try creating an |
I don't know what to do with that last comment. I found the "Custom::S3AutoDeleteObjectsCustomResourceProvider": {
"id": "Custom::S3AutoDeleteObjectsCustomResourceProvider",
"path": "MyStack/Custom::S3AutoDeleteObjectsCustomResourceProvider",
"children": {
"Handler": {
"id": "Handler",
"path": "MyStack/Custom::S3AutoDeleteObjectsCustomResourceProvider/Handler",
"constructInfo": {
"fqn": "aws-cdk-lib.CfnResource",
"version": "2.88.0"
}
} |
Faced with the same issue. |
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
withautoDeleteObjects: true
, and when I destroy the stack, I noticed there was still a CloudWatch Log Group not cleaned up.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
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/core/lib/custom-resource-provider/custom-resource-provider.ts#L307
Other Information
No response
Acknowledgements
CDK version used
2.88.0 (build 5d497f9)
Environment details (OS name and version, etc.)
macOS 12.6.6
The text was updated successfully, but these errors were encountered: