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

fix(cloudwatch-actions): cannot add LambdaActions to alarms with the same id but different addresses #32057

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tmokmss
Copy link
Contributor

@tmokmss tmokmss commented Nov 8, 2024

Issue # (if applicable)

Closes #30754.

Reason for this change

As decribed in the linked issue, the permission ids must be unique per Lambda function, and we cannot use alarm's costruct id to generate a permission id because alarm ids are not necessarily unique. To make sure its uniquenss, we use node address instead. A node address is guaranteed to be unique in a construct tree, so safe to use in permission id.

Description of changes

Because Lambda's resource policy (permission) is stateless, re-creating it with different logical ID is not a breaking change, as per the doc:

Not all template changes are breaking changes! Consider a user that has created a Stack using the previous version of the library, has updated their version of the CDK library and is now deploying an update. A behavior change is breaking if:
The update cannot be applied at all
The update can be applied but causes service interruption or data loss.

That is why this PR just removes the feature flag and replaced the permission id code instead of adding another feature flag, which would add more complexity to the behavior and UX if we had 2 similar flags related with this feature.

When you deploy an existing stack after this patch, CFn deploys in the following order:

  1. start deployment
  2. create a permission with new logical ID
  3. delete a permission with old logical ID
  4. finish deployment

So the permission for an alarm is active at any phase of the deployment.

Description of how you validated changes

add unit test and run integ test to confrim it deploys without disruption.

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 November 8, 2024 02:27
@github-actions github-actions bot added bug This issue is a bug. effort/small Small work item – less than a day of effort p2 star-contributor [Pilot] contributed between 25-49 PRs to the CDK labels Nov 8, 2024
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.

@aws-cdk-automation aws-cdk-automation dismissed their stale review November 8, 2024 02:35

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@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 Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. star-contributor [Pilot] contributed between 25-49 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cloudwatch-actions: cannot add LambdaActions to alarms with the same id but different addresses
2 participants