Skip to content

chore(s3): additional documentation for addToResourcePolicy. #15761

Merged
mergify[bot] merged 4 commits intoaws:masterfrom
otaviomacedo:add-policy-s3-doc
Jul 27, 2021
Merged

chore(s3): additional documentation for addToResourcePolicy. #15761
mergify[bot] merged 4 commits intoaws:masterfrom
otaviomacedo:add-policy-s3-doc

Conversation

@otaviomacedo
Copy link
Copy Markdown
Contributor

@otaviomacedo otaviomacedo commented Jul 26, 2021

This is to clarify that in some cases the policy will not be added and the result should be checked.

Closes #6548 and #7370.


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

…to clarify that in some cases the policy will not be added and the result should be checked.
@otaviomacedo otaviomacedo requested review from eladb and iliapolo July 26, 2021 11:02
@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented Jul 26, 2021

@otaviomacedo otaviomacedo requested a review from a team July 26, 2021 11:02
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jul 26, 2021
@nija-at nija-at added the pr/do-not-merge This PR should not be merged at this time. label Jul 26, 2021
```ts
const bucket = new Bucket(this, 'MyBucket');
bucket.addToResourcePolicy(new iam.PolicyStatement({
const result = bucket.addToResourcePolicy(new iam.PolicyStatement({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note for the future -

I'm not a big fan of this behaviour. Ideally, this API should fail if the 'add' does not occur. It's feels counter intuitive, poor ergonomics, that an action 'add' doesn't actually 'add' in some cases.

We should have added a second API tryAddToResourcePolicy() that does not fail in such cases.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. I can create this new API.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Wondering if this API has been created and whether this can fail more loudly! The silent failure of addToResourcePolicy is very confusing (per #6548) and it's not clear under what circumstances a person should know to check for success.

@otaviomacedo otaviomacedo removed the pr/do-not-merge This PR should not be merged at this time. label Jul 27, 2021
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jul 27, 2021

Thank you for contributing! Your pull request will be updated from master 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
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: dad7ae5
  • 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 9451b33 into aws:master Jul 27, 2021
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jul 27, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@otaviomacedo otaviomacedo deleted the add-policy-s3-doc branch July 27, 2021 08:26
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Aug 3, 2021
This is to clarify that in some cases the policy will not be added and the result should be checked.

Closes aws#6548 and aws#7370.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this pull request Aug 26, 2021
This is to clarify that in some cases the policy will not be added and the result should be checked.

Closes aws#6548 and aws#7370.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

S3 Bucket Policy Changes Not Recognized As A Change on CDK Deploy

4 participants