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): add bucket policy dependency to notification resource #30053

Merged
merged 5 commits into from
May 13, 2024

Conversation

yerzhan7
Copy link
Contributor

@yerzhan7 yerzhan7 commented May 3, 2024

Issue

Closes #27600.
Closes #16811.

Reason for this change

PutBucketPolicy and PutBucketNotification API calls are happening at the same time and causing race condition because S3 does not allow parallel bucket edits.

Description of changes

Add dependency on bucket policy to custom resource so that PutBucketPolicy API call is always executed before PutBucketNotification.

Description of how you validated changes

I've reproduced the bug locally and this solution fixed it.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added bug This issue is a bug. p1 valued-contributor [Pilot] contributed between 6-12 PRs to the CDK labels May 3, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team May 3, 2024 16:04
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 May 4, 2024 16:24

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

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label May 4, 2024
@github-actions github-actions bot added the effort/small Small work item – less than a day of effort label May 4, 2024
Copy link
Contributor

@GavinZZ GavinZZ left a comment

Choose a reason for hiding this comment

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

I'd like to hear your thought on the dependency solution over the exponential backoff/retry solution. I worry that this fix doesn't fix all issues but only the race condition between adding bucket policy and put bucket notfications. If there's another race condition between two other bucket actions, then the transient issue still persists.

@yerzhan7
Copy link
Contributor Author

If there's another race condition between two other bucket actions, then the transient issue still persists.

From my quick testing there are no race conditions with other S3 L1 constructs. (AWS::S3::AccessPoint, AWS::S3::StorageLens, AWS::S3::MultiRegionAccessPoint)

So, it looks like S3 has only 2 conflicting CFN bucket resources: AWS::S3::Bucket and AWS::S3::BucketPolicy. Resource Custom::S3BucketNotifications already depends on AWS::S3::Bucket. In this PR I am adding additional dependency on AWS::S3::BucketPolicy.

I'd like to hear your thought on the dependency solution over the exponential backoff/retry solution.

If we add retry logic for PutNotification API inside Custom Resource then CFN stack would still fail for AWS::S3::BucketPolicy resource because we cannot add exponential backoff to L1 bucket policy construct.

GavinZZ
GavinZZ previously approved these changes May 13, 2024
Copy link
Contributor

@GavinZZ GavinZZ left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for drafting the PR and answering my questions.

Copy link
Contributor

mergify bot commented May 13, 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 May 13, 2024
Copy link
Contributor

mergify bot commented May 13, 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).

@mergify mergify bot dismissed GavinZZ’s stale review May 13, 2024 21:09

Pull request has been modified.

Copy link
Contributor

mergify bot commented May 13, 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

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: fd372f4
  • 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 71986ff into aws:main May 13, 2024
9 checks passed
Copy link
Contributor

mergify bot commented May 13, 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).

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 p1 valued-contributor [Pilot] contributed between 6-12 PRs to the CDK
Projects
None yet
3 participants