-
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
fix(s3): unable to update the s3 event notifications on an existing S3 bucket #31431
Conversation
There was a problem hiding this 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.
Hello everyone, here are my 2 cents. THIS IS NOT RELATED TO SORT PROBLEMS (or not only) In CDK v2.3 the method used to verify if a notification configuration was external was based on the following check (this is from the Custom Resource behind aws_s3_notifications.LambdaDestination resource): In CDK v2.136 the method is this one (not checked when this change was introduced):
The function with_id(n) is this one:
The built-in function hash does not return the same value across different instances of python even if the input is the same. The Custom Resource will treat as external_notifications even the ones that are not, leading to duplicates |
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
This comment has been addressed in the issue discussion: #31303 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the changes LGTM, thanks for fixing the issue.
I approved the PR but added a |
Thanks @GavinZZ , discussed with @xazhao , we would like to confirm one that its not affecting anything in custom resources that are related to this and also test out a successful update scenario before merging. Here's an example to illustrate a potential regression (from analysis): const bucket = new s3.Bucket(this, 'MyBucket');
// Existing notification configuration
bucket.addEventNotification(
s3.EventType.OBJECT_CREATED,
new s3n.LambdaDestination(myLambda),
{ prefix: 'uploads/', suffix: '.jpg' }
);
// After deploying with the old logic, the notification has a specific hash identifier
// When updating the stack with the new logic:
// The same notification might be perceived as different due to the new sorting method
// CDK might attempt to remove the "old" notification and create a "new" one
// This could lead to temporary loss of notifications or duplicate notifications |
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 CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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). |
Comments on closed issues and PRs are hard for our team to see. |
Issue # (if applicable)
Closes #31303.
Reason for this change
During the update S3 bucket notifications, if there are multiple filter rules involved, the order of filter rules is different from CFN event notifications and S3 get notifications call. This will result different hash value which makes CDK unable to recognize s3 notifications created by the stack itself.
Description of changes
Sort the notifications filter rules by key when calculating the hash value.
Description of how you validated changes
Manually tested and integration tests.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license