forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cloudfront-origins): list access level for 404 response (aws#32059)
### Issue # (if applicable) Closes aws#13983. Closes aws#31689. ### Reason for this change When we want to receive HTTP 404 response where the requested object does not exist, s3:ListBucket permission is needed in the S3 bucket policy. Unlike `errorResponses` to convert 403 response to 404, This is useful to distinguish between responses blocked by WAF (403) and responses where the file does not exist (404). ### Description of changes Added a new `AccessLevel.LIST` to allow s3:ListBucket. ### Description of how you validated changes Unit test and integration test. The integ test also tests the response is 404. ### 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*
- Loading branch information
Showing
14 changed files
with
31,793 additions
and
23 deletions.
There are no files selected for viewing
30,570 changes: 30,570 additions & 0 deletions
30,570
...ot/asset.b98abee59e034ed29eeb601684dc34752baa86509a7d457d72305d4e19ecc80b.bundle/index.js
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...nteg/test/aws-cloudfront-origins/test/integ.s3-origin-oac-list-access.js.snapshot/cdk.out
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
...rigin-oac-list-access.js.snapshot/cloudfront-s3-bucket-origin-oac-list-access.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
172 changes: 172 additions & 0 deletions
172
...gin-oac-list-access.js.snapshot/cloudfront-s3-bucket-origin-oac-list-access.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
{ | ||
"Resources": { | ||
"Bucket83908E77": { | ||
"Type": "AWS::S3::Bucket", | ||
"UpdateReplacePolicy": "Delete", | ||
"DeletionPolicy": "Delete" | ||
}, | ||
"BucketPolicyE9A3008A": { | ||
"Type": "AWS::S3::BucketPolicy", | ||
"Properties": { | ||
"Bucket": { | ||
"Ref": "Bucket83908E77" | ||
}, | ||
"PolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"s3:GetObject", | ||
"s3:ListBucket" | ||
], | ||
"Condition": { | ||
"StringEquals": { | ||
"AWS:SourceArn": { | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":cloudfront::", | ||
{ | ||
"Ref": "AWS::AccountId" | ||
}, | ||
":distribution/", | ||
{ | ||
"Ref": "Distribution830FAC52" | ||
} | ||
] | ||
] | ||
} | ||
} | ||
}, | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "cloudfront.amazonaws.com" | ||
}, | ||
"Resource": [ | ||
{ | ||
"Fn::GetAtt": [ | ||
"Bucket83908E77", | ||
"Arn" | ||
] | ||
}, | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
{ | ||
"Fn::GetAtt": [ | ||
"Bucket83908E77", | ||
"Arn" | ||
] | ||
}, | ||
"/*" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
} | ||
} | ||
}, | ||
"DistributionOrigin1S3OriginAccessControlEB606076": { | ||
"Type": "AWS::CloudFront::OriginAccessControl", | ||
"Properties": { | ||
"OriginAccessControlConfig": { | ||
"Name": "cloudfronts3bucketoriginoaclOrigin1S3OriginAccessControl5D8868CB", | ||
"OriginAccessControlOriginType": "s3", | ||
"SigningBehavior": "always", | ||
"SigningProtocol": "sigv4" | ||
} | ||
} | ||
}, | ||
"Distribution830FAC52": { | ||
"Type": "AWS::CloudFront::Distribution", | ||
"Properties": { | ||
"DistributionConfig": { | ||
"DefaultCacheBehavior": { | ||
"CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6", | ||
"Compress": true, | ||
"TargetOriginId": "cloudfronts3bucketoriginoaclistaccessDistributionOrigin11CECE99D", | ||
"ViewerProtocolPolicy": "allow-all" | ||
}, | ||
"DefaultRootObject": "index.html", | ||
"Enabled": true, | ||
"HttpVersion": "http2", | ||
"IPV6Enabled": true, | ||
"Origins": [ | ||
{ | ||
"DomainName": { | ||
"Fn::GetAtt": [ | ||
"Bucket83908E77", | ||
"RegionalDomainName" | ||
] | ||
}, | ||
"Id": "cloudfronts3bucketoriginoaclistaccessDistributionOrigin11CECE99D", | ||
"OriginAccessControlId": { | ||
"Fn::GetAtt": [ | ||
"DistributionOrigin1S3OriginAccessControlEB606076", | ||
"Id" | ||
] | ||
}, | ||
"S3OriginConfig": { | ||
"OriginAccessIdentity": "" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"Outputs": { | ||
"ExportsOutputFnGetAttDistribution830FAC52DomainNameBEB09E30": { | ||
"Value": { | ||
"Fn::GetAtt": [ | ||
"Distribution830FAC52", | ||
"DomainName" | ||
] | ||
}, | ||
"Export": { | ||
"Name": "cloudfront-s3-bucket-origin-oac-list-access:ExportsOutputFnGetAttDistribution830FAC52DomainNameBEB09E30" | ||
} | ||
} | ||
}, | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...g/test/aws-cloudfront-origins/test/integ.s3-origin-oac-list-access.js.snapshot/integ.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
170 changes: 170 additions & 0 deletions
170
...est/aws-cloudfront-origins/test/integ.s3-origin-oac-list-access.js.snapshot/manifest.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.