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): add cleanup lambda #18448

Closed
2 tasks done
RichiCoder1 opened this issue Jan 15, 2022 · 5 comments · Fixed by #26580
Closed
2 tasks done

(aws-synthetics): add cleanup lambda #18448

RichiCoder1 opened this issue Jan 15, 2022 · 5 comments · Fixed by #26580
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. p1

Comments

@RichiCoder1
Copy link
Contributor

Description

Currently, when you delete a synthetic it leaves behind a massive set of detrius. This includes CW resources, buckets, lambdas, and other resources. This is a limitation of the Synthetics API where it will not explicitly delete resources left behind.

Use Case

To fully cleanup resources upon stack deletion.

Proposed Solution

Similar to S3, provision an additional lambda that fires upon Canary deletion and removes all the associated Canary resources.

Other information

No response

Acknowledge

  • I may be able to implement this feature request
  • This feature might incur a breaking change
@RichiCoder1 RichiCoder1 added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jan 15, 2022
@github-actions github-actions bot added the @aws-cdk/aws-synthetics Related to Amazon CloudWatch Synthetics label Jan 15, 2022
@kaizencc kaizencc added p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jan 15, 2022
@kaizencc
Copy link
Contributor

I like the idea! Seems doable with a custom resource like s3.

@kaizencc kaizencc removed their assignment Jan 15, 2022
@RichiCoder1
Copy link
Contributor Author

RichiCoder1 commented Mar 5, 2022

For this, s3 has an option like autoDeleteObjects. Would in this case it be a prop like autoDeleteCanaryResources? Can't think of a better name.

The end result behavior would be like S3 Auto Delete where it'll apply a tag, and on deletion of said tagged resource the CR will invoked to cleanup the underlying runtime Lambda. Do/should we cleanup CloudWatch stuff? I don't think anything else does.
Also assuming that if a bucket isn't provided, the auto created bucket would have autoDeleteObjects set to the same value as autoDeleteCanaryResources, it's retention policy will match the Canary's, and then CF will do it's normal thing cleaning it up.

@kaizencc
Copy link
Contributor

Looks like canaries can now be set with a DeleteLambdaResourcesOnCanaryDeletion property. I haven't tested it, but by the sound of the property it looks like the lambda resources at least can be auto-deleted. We can add that property into the L2 and be slightly better off than we were before.

@RichiCoder1
Copy link
Contributor Author

RichiCoder1 commented Jan 20, 2023

Yup, that's correct! Thank goodness too. It's been a sec, but I can submit a PR to add that property.

@mergify mergify bot closed this as completed in #26580 Aug 23, 2023
mergify bot pushed a commit that referenced this issue Aug 23, 2023
)

Synthetics [used](https://aws.amazon.com/about-aws/whats-new/2022/05/amazon-cloudwatch-synthetics-support-canary-resources-deletion/) to have a property `deleteLambdaResourceOnCanaryDeletion` that has since been deprecated and erased from cloudformation docs. Although this property still works today synthetics makes no promises that this is supported in the future.

Here in CDK land, this PR serves as a replacement to the `deleteLambdaResourceOnCanaryDeletion` property (called `enableAutoDeleteLambdas` on the L2 Canary) by implementing a custom resource similar to what we have in S3 and ECR.

**This PR deprecates `enableAutoDeleteLambdas` in favor of `cleanup: cleanup.LAMBDA`, an enum that achieves the same thing but via custom resource**

Closes #18448

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️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.

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. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants