-
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-notifications): cdk destroy deletes external/existing s3 notification events #29939
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fcbff13
fix(s3-notifications): cdk destroy deletes external/existing s3 notif…
GavinZZ cc054de
Update tests
GavinZZ 28cf3d4
Update tests
GavinZZ aeb003e
Update integ tests
GavinZZ cb96945
Merge branch 'main' into yuanhaoz/fix_s3_notifications
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,8 +95,8 @@ def test_create(self, _, put: MagicMock): | |
index.handler(event, {}) | ||
|
||
put.assert_called_once_with( | ||
event["ResourceProperties"]["BucketName"], | ||
event["ResourceProperties"]["NotificationConfiguration"], | ||
Bucket=event["ResourceProperties"]["BucketName"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to update this test file because this PR only updated the handler file but didn't change or run the test files. This results in all these tests failing. |
||
NotificationConfiguration=event["ResourceProperties"]["NotificationConfiguration"], | ||
) | ||
|
||
@patch("index.put_bucket_notification_configuration") | ||
|
@@ -108,8 +108,8 @@ def test_update(self, _, put): | |
index.handler(event, {}) | ||
|
||
put.assert_called_once_with( | ||
event["ResourceProperties"]["BucketName"], | ||
event["ResourceProperties"]["NotificationConfiguration"], | ||
Bucket=event["ResourceProperties"]["BucketName"], | ||
NotificationConfiguration=event["ResourceProperties"]["NotificationConfiguration"], | ||
) | ||
|
||
@patch("index.put_bucket_notification_configuration") | ||
|
@@ -120,7 +120,7 @@ def test_delete(self, _, put: MagicMock): | |
|
||
index.handler(event, {}) | ||
|
||
put.assert_called_once_with(event["ResourceProperties"]["BucketName"], {}) | ||
put.assert_called_once_with(Bucket=event["ResourceProperties"]["BucketName"], NotificationConfiguration={}) | ||
|
||
|
||
class UnmanagedCleanBucketTest(unittest.TestCase): | ||
|
@@ -136,8 +136,8 @@ def test_create(self, _, get: MagicMock, put: MagicMock): | |
index.handler(event, {}) | ||
|
||
put.assert_called_once_with( | ||
event["ResourceProperties"]["BucketName"], | ||
event["ResourceProperties"]["NotificationConfiguration"], | ||
Bucket=event["ResourceProperties"]["BucketName"], | ||
NotificationConfiguration=event["ResourceProperties"]["NotificationConfiguration"], | ||
) | ||
|
||
@patch("index.put_bucket_notification_configuration") | ||
|
@@ -152,8 +152,8 @@ def test_create_with_eventbridge(self, _, get: MagicMock, put: MagicMock): | |
index.handler(event, {}) | ||
|
||
put.assert_called_once_with( | ||
event["ResourceProperties"]["BucketName"], | ||
event["ResourceProperties"]["NotificationConfiguration"], | ||
Bucket=event["ResourceProperties"]["BucketName"], | ||
NotificationConfiguration=event["ResourceProperties"]["NotificationConfiguration"], | ||
) | ||
|
||
@patch("index.put_bucket_notification_configuration") | ||
|
@@ -170,8 +170,11 @@ def test_update(self, _, get: MagicMock, put: MagicMock): | |
index.handler(event, {}) | ||
|
||
put.assert_called_once_with( | ||
event["ResourceProperties"]["BucketName"], | ||
event["ResourceProperties"]["NotificationConfiguration"], | ||
Bucket=event["ResourceProperties"]["BucketName"], | ||
NotificationConfiguration=merge_notification_configurations( | ||
current_notifications, | ||
event["ResourceProperties"]["NotificationConfiguration"] | ||
), | ||
) | ||
|
||
@patch("index.put_bucket_notification_configuration") | ||
|
@@ -188,8 +191,11 @@ def test_update_with_eventbridge(self, _, get: MagicMock, put: MagicMock): | |
index.handler(event, {}) | ||
|
||
put.assert_called_once_with( | ||
event["ResourceProperties"]["BucketName"], | ||
event["ResourceProperties"]["NotificationConfiguration"], | ||
Bucket=event["ResourceProperties"]["BucketName"], | ||
NotificationConfiguration=merge_notification_configurations( | ||
current_notifications, | ||
event["ResourceProperties"]["NotificationConfiguration"] | ||
), | ||
) | ||
|
||
|
||
|
@@ -207,9 +213,9 @@ def test_update_with_existing_eventbridge(self, _, get: MagicMock, put: MagicMoc | |
index.handler(event, {}) | ||
|
||
put.assert_called_once_with( | ||
event["ResourceProperties"]["BucketName"], | ||
merge_notification_configurations( | ||
make_eventbridge_configuration(), | ||
Bucket=event["ResourceProperties"]["BucketName"], | ||
NotificationConfiguration=merge_notification_configurations( | ||
current_notifications, | ||
event["ResourceProperties"]["NotificationConfiguration"], | ||
), | ||
) | ||
|
@@ -228,8 +234,8 @@ def test_delete(self, _, get: MagicMock, put: MagicMock): | |
index.handler(event, {}) | ||
|
||
put.assert_called_once_with( | ||
event["ResourceProperties"]["BucketName"], | ||
make_empty_notification_configuration(), | ||
Bucket=event["ResourceProperties"]["BucketName"], | ||
NotificationConfiguration=make_empty_notification_configuration(), | ||
) | ||
|
||
@patch("index.put_bucket_notification_configuration") | ||
|
@@ -246,8 +252,8 @@ def test_delete_with_eventbridge_should_not_remove_eventbridge(self, _, get: Mag | |
index.handler(event, {}) | ||
|
||
put.assert_called_once_with( | ||
event["ResourceProperties"]["BucketName"], | ||
make_empty_notification_configuration_with_eventbridge(), | ||
Bucket=event["ResourceProperties"]["BucketName"], | ||
NotificationConfiguration=make_empty_notification_configuration_with_eventbridge(), | ||
) | ||
|
||
|
||
|
@@ -266,8 +272,8 @@ def test_create(self, _, get: MagicMock, put: MagicMock): | |
index.handler(event, {}) | ||
|
||
put.assert_called_once_with( | ||
event["ResourceProperties"]["BucketName"], | ||
merge_notification_configurations( | ||
Bucket=event["ResourceProperties"]["BucketName"], | ||
NotificationConfiguration=merge_notification_configurations( | ||
current_notifications, | ||
event["ResourceProperties"]["NotificationConfiguration"], | ||
), | ||
|
@@ -287,8 +293,8 @@ def test_create_with_eventbridge(self, _, get: MagicMock, put: MagicMock): | |
index.handler(event, {}) | ||
|
||
put.assert_called_once_with( | ||
event["ResourceProperties"]["BucketName"], | ||
merge_notification_configurations( | ||
Bucket=event["ResourceProperties"]["BucketName"], | ||
NotificationConfiguration=merge_notification_configurations( | ||
current_notifications, | ||
event["ResourceProperties"]["NotificationConfiguration"], | ||
), | ||
|
@@ -308,8 +314,8 @@ def test_create_with_existing_eventbridge(self, _, get: MagicMock, put: MagicMoc | |
index.handler(event, {}) | ||
|
||
put.assert_called_once_with( | ||
event["ResourceProperties"]["BucketName"], | ||
merge_notification_configurations( | ||
Bucket=event["ResourceProperties"]["BucketName"], | ||
NotificationConfiguration=merge_notification_configurations( | ||
current_notifications, | ||
event["ResourceProperties"]["NotificationConfiguration"], | ||
), | ||
|
@@ -329,8 +335,8 @@ def test_update(self, _, get: MagicMock, put: MagicMock): | |
index.handler(event, {}) | ||
|
||
put.assert_called_once_with( | ||
event["ResourceProperties"]["BucketName"], | ||
merge_notification_configurations( | ||
Bucket=event["ResourceProperties"]["BucketName"], | ||
NotificationConfiguration=merge_notification_configurations( | ||
current_notifications, | ||
event["ResourceProperties"]["NotificationConfiguration"], | ||
), | ||
|
@@ -350,8 +356,8 @@ def test_update_with_eventbridge(self, _, get: MagicMock, put: MagicMock): | |
index.handler(event, {}) | ||
|
||
put.assert_called_once_with( | ||
event["ResourceProperties"]["BucketName"], | ||
merge_notification_configurations( | ||
Bucket=event["ResourceProperties"]["BucketName"], | ||
NotificationConfiguration=merge_notification_configurations( | ||
current_notifications, | ||
event["ResourceProperties"]["NotificationConfiguration"], | ||
), | ||
|
@@ -371,8 +377,8 @@ def test_update_without_eventbridge_should_not_remove_existing_eventbridge(self, | |
index.handler(event, {}) | ||
|
||
put.assert_called_once_with( | ||
event["ResourceProperties"]["BucketName"], | ||
merge_notification_configurations( | ||
Bucket=event["ResourceProperties"]["BucketName"], | ||
NotificationConfiguration=merge_notification_configurations( | ||
current_notifications, | ||
event["ResourceProperties"]["NotificationConfiguration"], | ||
), | ||
|
@@ -392,8 +398,8 @@ def test_delete(self, _, get: MagicMock, put: MagicMock): | |
index.handler(event, {}) | ||
|
||
put.assert_called_once_with( | ||
event["ResourceProperties"]["BucketName"], | ||
current_notifications, | ||
Bucket=event["ResourceProperties"]["BucketName"], | ||
NotificationConfiguration=current_notifications, | ||
) | ||
|
||
@patch("index.put_bucket_notification_configuration") | ||
|
@@ -410,8 +416,8 @@ def test_delete_with_eventbridge_should_not_remove_eventbridge(self, _, get: Mag | |
index.handler(event, {}) | ||
|
||
put.assert_called_once_with( | ||
event["ResourceProperties"]["BucketName"], | ||
current_notifications, | ||
Bucket=event["ResourceProperties"]["BucketName"], | ||
NotificationConfiguration=current_notifications, | ||
) | ||
|
||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Falling back to the previous correct solution 37be7b9#diff-00d1f29e73955f487795d4a9873bcff824e70d6268e7926e44b7defb31b4ecb1L74