-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
aws_s3: BucketNotification in owning stack deletes BucketNotifications from other stacks #30607
Comments
Yes I can reproduce that by following your steps. I think we need to look into the implementation from the custom resource to get it fixed. |
It seems to me like a reasonable solution (the one I suggested) is to not have the special case for the owning stack (managed). If all the code related to managed was removed and just used the code path for "unmanaged" it seems like it would be a lot safer? |
I agree separating Also it's the same issue as #29653 |
…tions from other stacks (#31091) ### Issue # (if applicable) Closes #30607. ### Reason for this change There's a bug reported in the Github issue that bucket notifications in owing stack will remove all notifications added in imported stack. This is because we treated the bucket as `managed` hence we use bucket notifications in that stack as source of truth. In the `unmanaged` path, we already filtered out external notifications it should handle both scenarios when the bucket is managed or unmanaged. ### Description of changes Always set `Managed` property to false when the feature flag is enabled. Here we introduce a feature flag to prevent it breaking current customers. ### Description of how you validated changes Added unit tests. Integrations test can't validate this change because we need to deploy twice to actually see the change. Also tested manually. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Comments on closed issues and PRs are hard for our team to see. |
…tions from other stacks (aws#31091) ### Issue # (if applicable) Closes aws#30607. ### Reason for this change There's a bug reported in the Github issue that bucket notifications in owing stack will remove all notifications added in imported stack. This is because we treated the bucket as `managed` hence we use bucket notifications in that stack as source of truth. In the `unmanaged` path, we already filtered out external notifications it should handle both scenarios when the bucket is managed or unmanaged. ### Description of changes Always set `Managed` property to false when the feature flag is enabled. Here we introduce a feature flag to prevent it breaking current customers. ### Description of how you validated changes Added unit tests. Integrations test can't validate this change because we need to deploy twice to actually see the change. Also tested manually. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Describe the bug
When making changes to the S3 event notifications in the stack that owns an S3 Bucket (on
Bucket
), it deletes event notifications for the bucket that have been configured in other stacks (onIBucket
).Expected Behavior
Event notifications configured in other stacks should not be deleted.
Current Behavior
Event notifications configured in other stacks are being deleted.
Reproduction Steps
// stack 1 new Bucket(this, 'Bucket', { bucketName: 'bucketname', + eventBridgeEnabled: true, });
The event handler configured and deployed in step 2 will be deleted when doing step 3.
Possible Solution
Use the same logic for handling BucketNotifications in the stack that owns the Bucket as in other stack:
aws-cdk/packages/@aws-cdk/custom-resource-handlers/lib/aws-s3/notifications-resource-handler/index.py
Line 37 in 7360a88
Additional Information/Context
This is happening for Bucket (unlike IBucket) cdk sets
Managed
property on the custom resource that manages event notifications to true.aws-cdk/packages/aws-cdk-lib/aws-s3/lib/notifications-resource/notifications-resource.ts
Line 120 in 71986ff
aws-cdk/packages/aws-cdk-lib/aws-s3/lib/notifications-resource/notifications-resource.ts
Line 135 in 71986ff
And the code in the custom resource lambda handler disregards externally set notifications if
Managed
is set to true.aws-cdk/packages/@aws-cdk/custom-resource-handlers/lib/aws-s3/notifications-resource-handler/index.py
Line 21 in 7360a88
CDK CLI Version
2.146.0 (build b368c78)
Framework Version
2.146.0
Node.js Version
v20.11.0
OS
macOS 14.3.1 (23D60)
Language
TypeScript
Language Version
5.5.2
Other information
Activating eventbridge for our S3 Bucket in cdk caused our site to break because a notification set up in another stack using cdk got deleted.
The text was updated successfully, but these errors were encountered: