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

feat(synthetics): cleanup provisioned lambda and layers for canary #32738

Merged
merged 21 commits into from
Jan 24, 2025

Conversation

badmintoncryer
Copy link
Contributor

Issue # (if applicable)

None

Reason for this change

For the Lambda and Layer used in Canary, the deletion of related resources is handled by a custom resource, but this functionality is now supported natively by CloudFormation.

https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html#cfn-synthetics-canary-provisionedresourcecleanup

Description of changes

  • Add provisionedResourceCleanup prop to CanaryProps
  • deprecate cleanup prop which uses custom resource

Describe any new or updated permissions being added

None

Description of how you validated changes

Add both unit and integ test

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team January 4, 2025 14:19
@github-actions github-actions bot added p2 distinguished-contributor [Pilot] contributed 50+ PRs to the CDK labels Jan 4, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@badmintoncryer badmintoncryer marked this pull request as draft January 4, 2025 14:26
@aws-cdk-automation aws-cdk-automation dismissed their stale review January 4, 2025 14:28

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Copy link

codecov bot commented Jan 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.57%. Comparing base (7329068) to head (ae988df).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #32738   +/-   ##
=======================================
  Coverage   81.57%   81.57%           
=======================================
  Files         227      227           
  Lines       13793    13793           
  Branches     2419     2419           
=======================================
  Hits        11251    11251           
  Misses       2270     2270           
  Partials      272      272           
Flag Coverage Δ
suite.unit 81.57% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk 80.99% <ø> (ø)
packages/aws-cdk-lib/core 82.17% <ø> (ø)

@badmintoncryer badmintoncryer marked this pull request as ready for review January 6, 2025 12:44
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jan 6, 2025
Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Left comments for minor adjustments

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please update the Deleting underlying resources on canary deletion paragraph with a description of the new attribute?

Copy link
Contributor Author

@badmintoncryer badmintoncryer Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh.. I've forgotten to update the readme. Thanks!

@@ -70,6 +70,8 @@ export enum Cleanup {
* Clean up the underlying Lambda function only. The user is
* responsible for cleaning up all other resources left behind
* by the Canary.
*
* @deprecated use provisionedResourceCleanup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we should deprecate the cleanup property instead 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made cleanup deprecated.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jan 6, 2025
@badmintoncryer
Copy link
Contributor Author

@lpizzinidev Thank you for your review! I've addressed your comments.

Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 7, 2025

const app = new App();

new IntegTest(app, 'SyntheticsCanaryProvisionedResourceCleanup', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add assertions to this test to GetCanary to get the Lambda layer, DeleteCanary and then verify the lambda layer does not exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gracelu0 I've updated integ test!

@gracelu0 gracelu0 removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 17, 2025
@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

gracelu0
gracelu0 previously approved these changes Jan 23, 2025
Copy link
Contributor

@gracelu0 gracelu0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing!

Copy link
Contributor

mergify bot commented Jan 23, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 23, 2025
Copy link
Contributor

mergify bot commented Jan 23, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@badmintoncryer
Copy link
Contributor Author

@mergify update

Copy link
Contributor

mergify bot commented Jan 23, 2025

update

❌ Mergify doesn't have permission to update

For security reasons, Mergify can't update this pull request. Try updating locally.
GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/README.md without workflows permission

@badmintoncryer
Copy link
Contributor Author

@mergify update

Copy link
Contributor

mergify bot commented Jan 23, 2025

update

✅ Branch has been successfully updated

@@ -345,6 +354,10 @@ export class Canary extends cdk.Resource implements ec2.IConnectable {
validateName(props.canaryName);
}

if (props.cleanup === Cleanup.LAMBDA && props.provisionedResourceCleanup) {
throw new Error('Cannot specify `provisionedResourceCleanup` when `cleanup` is set to `Cleanup.LAMBDA`. Use only `provisionedResourceCleanup`.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@badmintoncryer I think the build is failing due to this error: aws-cdk-lib: /codebuild/output/src1859401526/src/github.com/aws/aws-cdk/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts aws-cdk-lib: 358:13 error Expected a non-default error object to be thrown @cdklabs/no-throw-default-error

I think the error needs to be updated from Error to ValidationError due to this PR where we are now enforcing specific error types: #33079

@mergify mergify bot dismissed gracelu0’s stale review January 24, 2025 13:00

Pull request has been modified.

Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

@aws-cdk-automation aws-cdk-automation dismissed their stale review January 24, 2025 13:14

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 24, 2025
@gracelu0 gracelu0 self-assigned this Jan 24, 2025
Copy link
Contributor

mergify bot commented Jan 24, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: ae988df
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

mergify bot commented Jan 24, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit bdb4a59 into aws:main Jan 24, 2025
20 checks passed
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
distinguished-contributor [Pilot] contributed 50+ PRs to the CDK p2 pr/needs-maintainer-review This PR needs a review from a Core Team Member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants