Skip to content

Commit 315be88

Browse files
feat(cloudfront-origins): read versioned access level (#33038)
### Issue # (if applicable) Closes #33034 ### Reason for this change This allows creating an S3 bucket origin OriginAccessControl for access of versioned objects via CloudFront. ### Description of changes Added a new `AccessLevel.READ_VERSIONED`, to extend the list of the OAC access levels, which extends the S3 bucket policy to contain `s3:GetObjectVersion`. I followed the existing patterns for the different AccessLevels, to make the change as small as possible. This enables versioned S3 bucket origins to allow the CloudFront distribution to access object versions. ### Describe any new or updated permissions being added n/a ### Description of how you validated changes Added a new unit-test and a new integration test ### 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 afa3d1f commit 315be88

File tree

13 files changed

+31723
-3
lines changed

13 files changed

+31723
-3
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront-origins/test/integ.s3-origin-oac-read-versioned.js.snapshot/asset.bfcf4228d6660f50e81f19efdb64c6388dda6796296eb239decdff1dbc2f4981.bundle/index.js

+30,569
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-origins/test/integ.s3-origin-oac-read-versioned.js.snapshot/cloudfront-s3-bucket-origin-oac-read-versioned-access.assets.json

+19
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
@@ -0,0 +1,160 @@
1+
{
2+
"Resources": {
3+
"Bucket83908E77": {
4+
"Type": "AWS::S3::Bucket",
5+
"UpdateReplacePolicy": "Delete",
6+
"DeletionPolicy": "Delete"
7+
},
8+
"BucketPolicyE9A3008A": {
9+
"Type": "AWS::S3::BucketPolicy",
10+
"Properties": {
11+
"Bucket": {
12+
"Ref": "Bucket83908E77"
13+
},
14+
"PolicyDocument": {
15+
"Statement": [
16+
{
17+
"Action": [
18+
"s3:GetObject",
19+
"s3:GetObjectVersion"
20+
],
21+
"Condition": {
22+
"StringEquals": {
23+
"AWS:SourceArn": {
24+
"Fn::Join": [
25+
"",
26+
[
27+
"arn:",
28+
{
29+
"Ref": "AWS::Partition"
30+
},
31+
":cloudfront::",
32+
{
33+
"Ref": "AWS::AccountId"
34+
},
35+
":distribution/",
36+
{
37+
"Ref": "Distribution830FAC52"
38+
}
39+
]
40+
]
41+
}
42+
}
43+
},
44+
"Effect": "Allow",
45+
"Principal": {
46+
"Service": "cloudfront.amazonaws.com"
47+
},
48+
"Resource": {
49+
"Fn::Join": [
50+
"",
51+
[
52+
{
53+
"Fn::GetAtt": [
54+
"Bucket83908E77",
55+
"Arn"
56+
]
57+
},
58+
"/*"
59+
]
60+
]
61+
}
62+
}
63+
],
64+
"Version": "2012-10-17"
65+
}
66+
}
67+
},
68+
"DistributionOrigin1S3OriginAccessControlEB606076": {
69+
"Type": "AWS::CloudFront::OriginAccessControl",
70+
"Properties": {
71+
"OriginAccessControlConfig": {
72+
"Name": "cloudfronts3bucketoriginoacrOrigin1S3OriginAccessControlE3A6B956",
73+
"OriginAccessControlOriginType": "s3",
74+
"SigningBehavior": "always",
75+
"SigningProtocol": "sigv4"
76+
}
77+
}
78+
},
79+
"Distribution830FAC52": {
80+
"Type": "AWS::CloudFront::Distribution",
81+
"Properties": {
82+
"DistributionConfig": {
83+
"DefaultCacheBehavior": {
84+
"CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6",
85+
"Compress": true,
86+
"TargetOriginId": "cloudfronts3bucketoriginoacreadversionedaccessDistributionOrigin1920A1FBA",
87+
"ViewerProtocolPolicy": "allow-all"
88+
},
89+
"Enabled": true,
90+
"HttpVersion": "http2",
91+
"IPV6Enabled": true,
92+
"Origins": [
93+
{
94+
"DomainName": {
95+
"Fn::GetAtt": [
96+
"Bucket83908E77",
97+
"RegionalDomainName"
98+
]
99+
},
100+
"Id": "cloudfronts3bucketoriginoacreadversionedaccessDistributionOrigin1920A1FBA",
101+
"OriginAccessControlId": {
102+
"Fn::GetAtt": [
103+
"DistributionOrigin1S3OriginAccessControlEB606076",
104+
"Id"
105+
]
106+
},
107+
"S3OriginConfig": {
108+
"OriginAccessIdentity": ""
109+
}
110+
}
111+
]
112+
}
113+
}
114+
}
115+
},
116+
"Outputs": {
117+
"ExportsOutputRefBucket83908E7781C90AC0": {
118+
"Value": {
119+
"Ref": "Bucket83908E77"
120+
},
121+
"Export": {
122+
"Name": "cloudfront-s3-bucket-origin-oac-read-versioned-access:ExportsOutputRefBucket83908E7781C90AC0"
123+
}
124+
}
125+
},
126+
"Parameters": {
127+
"BootstrapVersion": {
128+
"Type": "AWS::SSM::Parameter::Value<String>",
129+
"Default": "/cdk-bootstrap/hnb659fds/version",
130+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
131+
}
132+
},
133+
"Rules": {
134+
"CheckBootstrapVersion": {
135+
"Assertions": [
136+
{
137+
"Assert": {
138+
"Fn::Not": [
139+
{
140+
"Fn::Contains": [
141+
[
142+
"1",
143+
"2",
144+
"3",
145+
"4",
146+
"5"
147+
],
148+
{
149+
"Ref": "BootstrapVersion"
150+
}
151+
]
152+
}
153+
]
154+
},
155+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
156+
}
157+
]
158+
}
159+
}
160+
}

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront-origins/test/integ.s3-origin-oac-read-versioned.js.snapshot/integ.json

+12
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-origins/test/integ.s3-origin-oac-read-versioned.js.snapshot/manifest.json

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

0 commit comments

Comments
 (0)