Skip to content

Commit bc80331

Browse files
authored
fix(cloudfront): avoid to sort TTLs when using Tokens in CachePolicy (#25920)
Closes #25795. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 8ab920b commit bc80331

11 files changed

+414
-37
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "32.0.0",
3+
"files": {
4+
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
5+
"source": {
6+
"path": "DistributionPoliciesDefaultTestDeployAssert1B8724D9.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"Parameters": {
3+
"BootstrapVersion": {
4+
"Type": "AWS::SSM::Parameter::Value<String>",
5+
"Default": "/cdk-bootstrap/hnb659fds/version",
6+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
7+
}
8+
},
9+
"Rules": {
10+
"CheckBootstrapVersion": {
11+
"Assertions": [
12+
{
13+
"Assert": {
14+
"Fn::Not": [
15+
{
16+
"Fn::Contains": [
17+
[
18+
"1",
19+
"2",
20+
"3",
21+
"4",
22+
"5"
23+
],
24+
{
25+
"Ref": "BootstrapVersion"
26+
}
27+
]
28+
}
29+
]
30+
},
31+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
32+
}
33+
]
34+
}
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"31.0.0"}
1+
{"version":"32.0.0"}

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-policies.js.snapshot/integ-distribution-policies.assets.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"version": "31.0.0",
2+
"version": "32.0.0",
33
"files": {
4-
"b775626104dd72b1b3fc9a1fb6e652212a0a0aa05be2d07ce372eaf29589c146": {
4+
"01042f10dd3272da413b201384cdf825a7467030c0db8a2d5bcfe10b45a30ced": {
55
"source": {
66
"path": "integ-distribution-policies.template.json",
77
"packaging": "file"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "b775626104dd72b1b3fc9a1fb6e652212a0a0aa05be2d07ce372eaf29589c146.json",
12+
"objectKey": "01042f10dd3272da413b201384cdf825a7467030c0db8a2d5bcfe10b45a30ced.json",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-policies.js.snapshot/integ-distribution-policies.template.json

+53-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,46 @@
2424
}
2525
}
2626
},
27+
"CachePolicyWithRefD7C98251": {
28+
"Type": "AWS::CloudFront::CachePolicy",
29+
"Properties": {
30+
"CachePolicyConfig": {
31+
"DefaultTTL": {
32+
"Ref": "DefaultTtlParam"
33+
},
34+
"MaxTTL": {
35+
"Ref": "MaxTtlParam"
36+
},
37+
"MinTTL": {
38+
"Ref": "MinTtlParam"
39+
},
40+
"Name": {
41+
"Fn::Join": [
42+
"",
43+
[
44+
"integdistributionpoliciesCachePolicyWithRef80C59B6E-",
45+
{
46+
"Ref": "AWS::Region"
47+
}
48+
]
49+
]
50+
},
51+
"ParametersInCacheKeyAndForwardedToOrigin": {
52+
"CookiesConfig": {
53+
"CookieBehavior": "none"
54+
},
55+
"EnableAcceptEncodingBrotli": false,
56+
"EnableAcceptEncodingGzip": false,
57+
"HeadersConfig": {
58+
"HeaderBehavior": "none"
59+
},
60+
"QueryStringsConfig": {
61+
"QueryStringBehavior": "none"
62+
}
63+
}
64+
}
65+
}
66+
},
2767
"OriginRequestPolicy3EFDB4FA": {
2868
"Type": "AWS::CloudFront::OriginRequestPolicy",
2969
"Properties": {
@@ -130,7 +170,7 @@
130170
"DistributionConfig": {
131171
"DefaultCacheBehavior": {
132172
"CachePolicyId": {
133-
"Ref": "CachePolicy26D8A535"
173+
"Ref": "CachePolicyWithRefD7C98251"
134174
},
135175
"Compress": true,
136176
"OriginRequestPolicyId": "b689b0a8-53d0-40ab-baf2-68738e2966ac",
@@ -157,6 +197,18 @@
157197
}
158198
},
159199
"Parameters": {
200+
"MinTtlParam": {
201+
"Type": "Number",
202+
"Default": "1000"
203+
},
204+
"DefaultTtlParam": {
205+
"Type": "Number",
206+
"Default": "2000"
207+
},
208+
"MaxTtlParam": {
209+
"Type": "Number",
210+
"Default": "3000"
211+
},
160212
"BootstrapVersion": {
161213
"Type": "AWS::SSM::Parameter::Value<String>",
162214
"Default": "/cdk-bootstrap/hnb659fds/version",
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
{
2-
"version": "31.0.0",
2+
"version": "32.0.0",
33
"testCases": {
4-
"integ.distribution-policies": {
4+
"DistributionPolicies/DefaultTest": {
55
"stacks": [
66
"integ-distribution-policies"
77
],
8-
"diffAssets": false,
9-
"stackUpdateWorkflow": true
8+
"assertionStack": "DistributionPolicies/DefaultTest/DeployAssert",
9+
"assertionStackName": "DistributionPoliciesDefaultTestDeployAssert1B8724D9"
1010
}
11-
},
12-
"synthContext": {},
13-
"enableLookups": false
11+
}
1412
}

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

+73-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "31.0.0",
2+
"version": "32.0.0",
33
"artifacts": {
44
"integ-distribution-policies.assets": {
55
"type": "cdk:asset-manifest",
@@ -17,7 +17,7 @@
1717
"validateOnSynth": false,
1818
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
1919
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
20-
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/b775626104dd72b1b3fc9a1fb6e652212a0a0aa05be2d07ce372eaf29589c146.json",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/01042f10dd3272da413b201384cdf825a7467030c0db8a2d5bcfe10b45a30ced.json",
2121
"requiresBootstrapStackVersion": 6,
2222
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
2323
"additionalDependencies": [
@@ -39,6 +39,30 @@
3939
"data": "CachePolicy26D8A535"
4040
}
4141
],
42+
"/integ-distribution-policies/MinTtlParam": [
43+
{
44+
"type": "aws:cdk:logicalId",
45+
"data": "MinTtlParam"
46+
}
47+
],
48+
"/integ-distribution-policies/DefaultTtlParam": [
49+
{
50+
"type": "aws:cdk:logicalId",
51+
"data": "DefaultTtlParam"
52+
}
53+
],
54+
"/integ-distribution-policies/MaxTtlParam": [
55+
{
56+
"type": "aws:cdk:logicalId",
57+
"data": "MaxTtlParam"
58+
}
59+
],
60+
"/integ-distribution-policies/CachePolicyWithRef/Resource": [
61+
{
62+
"type": "aws:cdk:logicalId",
63+
"data": "CachePolicyWithRefD7C98251"
64+
}
65+
],
4266
"/integ-distribution-policies/OriginRequestPolicy/Resource": [
4367
{
4468
"type": "aws:cdk:logicalId",
@@ -78,6 +102,53 @@
78102
},
79103
"displayName": "integ-distribution-policies"
80104
},
105+
"DistributionPoliciesDefaultTestDeployAssert1B8724D9.assets": {
106+
"type": "cdk:asset-manifest",
107+
"properties": {
108+
"file": "DistributionPoliciesDefaultTestDeployAssert1B8724D9.assets.json",
109+
"requiresBootstrapStackVersion": 6,
110+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
111+
}
112+
},
113+
"DistributionPoliciesDefaultTestDeployAssert1B8724D9": {
114+
"type": "aws:cloudformation:stack",
115+
"environment": "aws://unknown-account/unknown-region",
116+
"properties": {
117+
"templateFile": "DistributionPoliciesDefaultTestDeployAssert1B8724D9.template.json",
118+
"validateOnSynth": false,
119+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
120+
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
121+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
122+
"requiresBootstrapStackVersion": 6,
123+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
124+
"additionalDependencies": [
125+
"DistributionPoliciesDefaultTestDeployAssert1B8724D9.assets"
126+
],
127+
"lookupRole": {
128+
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
129+
"requiresBootstrapStackVersion": 8,
130+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
131+
}
132+
},
133+
"dependencies": [
134+
"DistributionPoliciesDefaultTestDeployAssert1B8724D9.assets"
135+
],
136+
"metadata": {
137+
"/DistributionPolicies/DefaultTest/DeployAssert/BootstrapVersion": [
138+
{
139+
"type": "aws:cdk:logicalId",
140+
"data": "BootstrapVersion"
141+
}
142+
],
143+
"/DistributionPolicies/DefaultTest/DeployAssert/CheckBootstrapVersion": [
144+
{
145+
"type": "aws:cdk:logicalId",
146+
"data": "CheckBootstrapVersion"
147+
}
148+
]
149+
},
150+
"displayName": "DistributionPolicies/DefaultTest/DeployAssert"
151+
},
81152
"Tree": {
82153
"type": "cdk:tree",
83154
"properties": {

0 commit comments

Comments
 (0)