Skip to content
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

aws synthetics: cleanup canary resources #29548

Open
2 tasks
lukasnagl opened this issue Mar 20, 2024 · 2 comments
Open
2 tasks

aws synthetics: cleanup canary resources #29548

lukasnagl opened this issue Mar 20, 2024 · 2 comments
Labels
@aws-cdk/aws-synthetics Related to Amazon CloudWatch Synthetics effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@lukasnagl
Copy link

Describe the feature

Upon stack deletion I noticed that Canary constructs left behind not only lambda functions, but S3 buckets (containing screenshots) as well. I would have expected all resources created by the canary to be deleted automatically, or at least having a retention option on the Canary construct.

Use Case

On deletion of a Canary construct, all resources (lambdas, s3 buckets,…) created for it should be deleted by default.

Proposed Solution

I believe #26580 went for a solution approach, but is limited to the lambda function for the canary. Maybe this can be extended to all resources, or even made the default instead of a separate cleanup configuration?

Other Information

I saw similar efforts in #18448, which added lambda deletion but did not resolve s3 bucket deletion to my knowledge.

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.130.0

Environment details (OS name and version, etc.)

irrelevant

@lukasnagl lukasnagl added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Mar 20, 2024
@github-actions github-actions bot added the @aws-cdk/aws-synthetics Related to Amazon CloudWatch Synthetics label Mar 20, 2024
@pahud
Copy link
Contributor

pahud commented Mar 20, 2024

Yes we probably can do that from here

if (props.cleanup === Cleanup.LAMBDA) {
this.cleanupUnderlyingResources();
}

Making this a p2 feature-request, please help us prioritize with 👍 .

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Mar 20, 2024
@sigJoe
Copy link
Contributor

sigJoe commented Mar 22, 2024

I was just about to create the same feature request, but in my mind the real issue is Log Groups rather than S3 buckets.

Here's my thoughts on the matter with a TLDR at the end:

S3 Buckets

When creating a Canary via CDK the stack output include an AWS::S3::Bucket object named MyCanaryArtifactsBucket... but it has DeletionPolicy: Retain so it doesn't get deleted by CFN. This isn't a good fit for the cleanupUnderlyingResources() function which is a separate Lambda, as that is for resources not created by the CloudFormation stack.

A workaround would be if you create the S3 Bucket separately then set the Canary artifactsBucketLocation parameter, you can specify the DeletionPolicy and retention of your choice. It would be a nice feature to pass Canary some logging properties and have it create a bucket with desired configuration.

Log Groups

Unlike S3 buckets and IAM roles, there's no workaround to manually create the log group. CDK can't do it because AWS doesn't allow it and the name isn't deterministic. The only way to handle this currently would be to add log group removal to that cleanup function.

Related issue: #23718

TLDR

  • Canary cleanup should include log groups
  • Canary cleanup has a workaround for deleting S3 buckets, but I agree there could be room for improvement
  • Other resources (IAM roles) are already handled appropriately.

(updated twice)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-synthetics Related to Amazon CloudWatch Synthetics effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

3 participants