Skip to content

Commit 4bf6fad

Browse files
authored
fix(s3): publicReadAccess causes deployment failure due to access denied 403 (#29632)
### Issue # (if applicable) Closes #29564 ### Reason for this change if you make a new s3 bucket ``` const staticBucket = new aws_s3.Bucket(s3Stack, `static-Bucket`, { bucketName: `static-bucket`, publicReadAccess: true, }) ``` While this is fine code and you can deploy it will fail in the middle with a generic access denied error not telling you what stopped it even if you are full admin. This happens due to the default deny all public access rule. ### Description of changes When users only enable `publicReadAccess` without configuring `blockPublicAccess` to disable it, we will raise an exception and throw an more appropriate error message for easier diagnosis. We do not want to directly disable `blockPublicAccess` as it feels like a weird behaviour. ### Description of how you validated changes New unit tests and updated integ tests ### 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*
1 parent 526d4ad commit 4bf6fad

File tree

12 files changed

+303
-61
lines changed

12 files changed

+303
-61
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.cloudfront-custom-s3.js.snapshot/cdk.out

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
"Bucket83908E77": {
44
"Type": "AWS::S3::Bucket",
55
"Properties": {
6+
"PublicAccessBlockConfiguration": {
7+
"BlockPublicAcls": false,
8+
"BlockPublicPolicy": false,
9+
"IgnorePublicAcls": false,
10+
"RestrictPublicBuckets": false
11+
},
612
"WebsiteConfiguration": {
713
"ErrorDocument": "404.html",
814
"IndexDocument": "index.html"

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.cloudfront-custom-s3.js.snapshot/integ.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.cloudfront-custom-s3.js.snapshot/integcloudfrontcustoms3DefaultTestDeployAssert2E08B1DA.assets.json

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.cloudfront-custom-s3.js.snapshot/integcloudfrontcustoms3DefaultTestDeployAssert2E08B1DA.template.json

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.cloudfront-custom-s3.js.snapshot/manifest.json

Lines changed: 69 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)