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(s3-notifications): cdk destroy deletes external/existing s3 notification events #29939

Merged
merged 5 commits into from
Apr 24, 2024

Conversation

GavinZZ
Copy link
Contributor

@GavinZZ GavinZZ commented Apr 23, 2024

Issue # (if applicable)

Closes #29004

Reason for this change

cdk destroy removes all event notifications configured on an existing S3 bucket instead of only CDK managed event notifications. This occurs whenever a stack that creates an event notification for an existing bucket is deleted or rolled back.

Description of changes

Add a Delete statement which will only remove the ones created from within the stack

Description of how you validated changes

Manually tested this.

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 April 23, 2024 21:24
@github-actions github-actions bot added bug This issue is a bug. effort/medium Medium work item – several days of effort p1 labels Apr 23, 2024
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Apr 23, 2024
@@ -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"],
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

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.

@GavinZZ GavinZZ added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Apr 23, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review April 23, 2024 21:37

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

elif request_type == 'Delete':
# For 'Delete' request, old parameter is an empty dict so we cannot use this to determine which are external
# notifications. Fall back to rely on the stack naming logic.
external_notifications[t] = [n for n in existing_notifications.get(t, []) if not n['Id'].startswith(f"{stack_id}-")]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aaythapa
Copy link
Contributor

Does this suggested fix not work? 37be7b9#r137776660

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Apr 24, 2024
@GavinZZ
Copy link
Contributor Author

GavinZZ commented Apr 24, 2024

Does this suggested fix not work? 37be7b9#r137776660

No, I added comment in code to explain why I had to do it this way. Basically the old parameter for delete is empty dict unlike update.

@aaythapa
Copy link
Contributor

Does this suggested fix not work? 37be7b9#r137776660

No, I added comment in code to explain why I had to do it this way. Basically the old parameter for delete is empty dict unlike update.

ah, didn't notice. LGTM

Copy link
Contributor

mergify bot commented Apr 24, 2024

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 Apr 24, 2024
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@mergify mergify bot merged commit 7360a88 into main Apr 24, 2024
15 checks passed
@mergify mergify bot deleted the yuanhaoz/fix_s3_notifications branch April 24, 2024 01:17
Copy link
Contributor

mergify bot commented Apr 24, 2024

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

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.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/medium Medium work item – several days of effort p1 pr-linter/exempt-integ-test The PR linter will not require integ test changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws_s3_notifications : CDK destroy deletes existing S3 event notifications
3 participants