Skip to content

Commit 7d70bf4

Browse files
feat(cloudfront-origins): response completion timeout (#35485)
### Issue # (if applicable) None ### Reason for this change AWS Cloudfront supports for configuring response completion timeout. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DownloadDistValuesOrigin.html#response-completion-timeout ### Description of changes Core Implementation - Added `responseCompletionTimeout`: Duration to OriginOptions interface - Added validation in OriginBase for 1-3600 seconds range - Updated `bind()` method to include property in CloudFormation output Origin Classes - `HttpOrigin` & `FunctionUrlOrigin`: Added validation to ensure `responseCompletionTimeout` >= `readTimeout` - `RestApiOrigin` & `LoadBalancerV2Origin`: Inherit validation through `HttpOrigin` ### Describe any new or updated permissions being added None ### Description of how you validated changes Add both unit and 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 fe2b7a6 commit 7d70bf4

19 files changed

+1353
-3
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront-origins/test/integ.origin-response-completion-timeout.js.snapshot/CloudFrontResponseCompletionTimeoutTestDefaultTestDeployAssert28BE7FDC.assets.json

Lines changed: 20 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-origins/test/integ.origin-response-completion-timeout.js.snapshot/CloudFrontResponseCompletionTimeoutTestDefaultTestDeployAssert28BE7FDC.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-origins/test/integ.origin-response-completion-timeout.js.snapshot/cdk.out

Lines changed: 1 addition & 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-origins/test/integ.origin-response-completion-timeout.js.snapshot/integ-cloudfront-response-completion-timeout.assets.json

Lines changed: 20 additions & 0 deletions
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,217 @@
1+
{
2+
"Resources": {
3+
"FunctionServiceRole675BB04A": {
4+
"Type": "AWS::IAM::Role",
5+
"Properties": {
6+
"AssumeRolePolicyDocument": {
7+
"Statement": [
8+
{
9+
"Action": "sts:AssumeRole",
10+
"Effect": "Allow",
11+
"Principal": {
12+
"Service": "lambda.amazonaws.com"
13+
}
14+
}
15+
],
16+
"Version": "2012-10-17"
17+
},
18+
"ManagedPolicyArns": [
19+
{
20+
"Fn::Join": [
21+
"",
22+
[
23+
"arn:",
24+
{
25+
"Ref": "AWS::Partition"
26+
},
27+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
28+
]
29+
]
30+
}
31+
]
32+
}
33+
},
34+
"Function76856677": {
35+
"Type": "AWS::Lambda::Function",
36+
"Properties": {
37+
"Code": {
38+
"ZipFile": "exports.handler = async () => ({ statusCode: 200, body: \"Hello from Lambda!\" });"
39+
},
40+
"Handler": "index.handler",
41+
"Role": {
42+
"Fn::GetAtt": [
43+
"FunctionServiceRole675BB04A",
44+
"Arn"
45+
]
46+
},
47+
"Runtime": "nodejs18.x"
48+
},
49+
"DependsOn": [
50+
"FunctionServiceRole675BB04A"
51+
]
52+
},
53+
"FunctionLogGroup55B80E27": {
54+
"Type": "AWS::Logs::LogGroup",
55+
"Properties": {
56+
"LogGroupName": {
57+
"Fn::Join": [
58+
"",
59+
[
60+
"/aws/lambda/",
61+
{
62+
"Ref": "Function76856677"
63+
}
64+
]
65+
]
66+
},
67+
"RetentionInDays": 731
68+
},
69+
"UpdateReplacePolicy": "Retain",
70+
"DeletionPolicy": "Retain"
71+
},
72+
"FunctionFunctionUrl08F79AC9": {
73+
"Type": "AWS::Lambda::Url",
74+
"Properties": {
75+
"AuthType": "NONE",
76+
"TargetFunctionArn": {
77+
"Fn::GetAtt": [
78+
"Function76856677",
79+
"Arn"
80+
]
81+
}
82+
}
83+
},
84+
"FunctioninvokefunctionurlA70D8F37": {
85+
"Type": "AWS::Lambda::Permission",
86+
"Properties": {
87+
"Action": "lambda:InvokeFunctionUrl",
88+
"FunctionName": {
89+
"Fn::GetAtt": [
90+
"Function76856677",
91+
"Arn"
92+
]
93+
},
94+
"FunctionUrlAuthType": "NONE",
95+
"Principal": "*"
96+
}
97+
},
98+
"Distribution830FAC52": {
99+
"Type": "AWS::CloudFront::Distribution",
100+
"Properties": {
101+
"DistributionConfig": {
102+
"CacheBehaviors": [
103+
{
104+
"CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6",
105+
"Compress": true,
106+
"PathPattern": "/api/*",
107+
"TargetOriginId": "integcloudfrontresponsecompletiontimeoutDistributionOrigin24E64923B",
108+
"ViewerProtocolPolicy": "allow-all"
109+
},
110+
{
111+
"CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6",
112+
"Compress": true,
113+
"PathPattern": "/files/*",
114+
"TargetOriginId": "integcloudfrontresponsecompletiontimeoutDistributionOrigin36D3F546F",
115+
"ViewerProtocolPolicy": "allow-all"
116+
}
117+
],
118+
"DefaultCacheBehavior": {
119+
"CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6",
120+
"Compress": true,
121+
"TargetOriginId": "integcloudfrontresponsecompletiontimeoutDistributionOrigin1B68EA04D",
122+
"ViewerProtocolPolicy": "allow-all"
123+
},
124+
"Enabled": true,
125+
"HttpVersion": "http2",
126+
"IPV6Enabled": true,
127+
"Origins": [
128+
{
129+
"CustomOriginConfig": {
130+
"OriginProtocolPolicy": "https-only",
131+
"OriginReadTimeout": 60,
132+
"OriginSSLProtocols": [
133+
"TLSv1.2"
134+
]
135+
},
136+
"DomainName": "example.com",
137+
"Id": "integcloudfrontresponsecompletiontimeoutDistributionOrigin1B68EA04D",
138+
"ResponseCompletionTimeout": 120
139+
},
140+
{
141+
"CustomOriginConfig": {
142+
"OriginProtocolPolicy": "https-only",
143+
"OriginReadTimeout": 30,
144+
"OriginSSLProtocols": [
145+
"TLSv1.2"
146+
]
147+
},
148+
"DomainName": {
149+
"Fn::Select": [
150+
2,
151+
{
152+
"Fn::Split": [
153+
"/",
154+
{
155+
"Fn::GetAtt": [
156+
"FunctionFunctionUrl08F79AC9",
157+
"FunctionUrl"
158+
]
159+
}
160+
]
161+
}
162+
]
163+
},
164+
"Id": "integcloudfrontresponsecompletiontimeoutDistributionOrigin24E64923B",
165+
"ResponseCompletionTimeout": 90
166+
},
167+
{
168+
"CustomOriginConfig": {
169+
"OriginProtocolPolicy": "https-only",
170+
"OriginSSLProtocols": [
171+
"TLSv1.2"
172+
]
173+
},
174+
"DomainName": "api.example.com",
175+
"Id": "integcloudfrontresponsecompletiontimeoutDistributionOrigin36D3F546F",
176+
"ResponseCompletionTimeout": 300
177+
}
178+
]
179+
}
180+
}
181+
}
182+
},
183+
"Parameters": {
184+
"BootstrapVersion": {
185+
"Type": "AWS::SSM::Parameter::Value<String>",
186+
"Default": "/cdk-bootstrap/hnb659fds/version",
187+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
188+
}
189+
},
190+
"Rules": {
191+
"CheckBootstrapVersion": {
192+
"Assertions": [
193+
{
194+
"Assert": {
195+
"Fn::Not": [
196+
{
197+
"Fn::Contains": [
198+
[
199+
"1",
200+
"2",
201+
"3",
202+
"4",
203+
"5"
204+
],
205+
{
206+
"Ref": "BootstrapVersion"
207+
}
208+
]
209+
}
210+
]
211+
},
212+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
213+
}
214+
]
215+
}
216+
}
217+
}

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront-origins/test/integ.origin-response-completion-timeout.js.snapshot/integ.json

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

0 commit comments

Comments
 (0)