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

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

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
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

+8-8
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

+19
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

+36
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

+69-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)