Skip to content

Commit 171fdcd

Browse files
authored
feat(cloudfront-origins): extend max keepaliveTimeout of HttpOrigin to 180 (#18837)
This pull request extends the maximum value of the keepaliveTimeout property for HttpOriginProps up to 180 seconds. This allows the use of the construct also in the case that a limit increase has been approved for CloudFront [origin keep-alive timeout quota](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesOriginKeepaliveTimeout). The 180 seconds cap should be AWS hard limit for that quota. This is related to #18697, which only extended the readTimeout, but keepaliveTimeout can also be increased. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent b2bba77 commit 171fdcd

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

packages/@aws-cdk/aws-cloudfront-origins/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,12 @@ const origin = new origins.LoadBalancerV2Origin(loadBalancer, {
7676
connectionAttempts: 3,
7777
connectionTimeout: Duration.seconds(5),
7878
readTimeout: Duration.seconds(45),
79+
keepaliveTimeout: Duration.seconds(45),
7980
protocolPolicy: cloudfront.OriginProtocolPolicy.MATCH_VIEWER,
8081
});
8182
```
8283

83-
Note that the `readTimeout` property can extend its value over 60 seconds only if a limit increase request for CloudFront origin response timeout
84+
Note that the `readTimeout` and `keepaliveTimeout` properties can extend their values over 60 seconds only if a limit increase request for CloudFront origin response timeout
8485
quota has been approved in the target account; otherwise, values over 60 seconds will produce an error at deploy time. Consider that this value is
8586
still limited to a maximum value of 180 seconds, which is a hard limit for that quota.
8687

packages/@aws-cdk/aws-cloudfront-origins/lib/http-origin.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ export interface HttpOriginProps extends cloudfront.OriginProps {
4646

4747
/**
4848
* Specifies how long, in seconds, CloudFront persists its connection to the origin.
49-
* The valid range is from 1 to 60 seconds, inclusive.
49+
* The valid range is from 1 to 180 seconds, inclusive.
50+
*
51+
* Note that values over 60 seconds are possible only after a limit increase request for the origin response timeout quota
52+
* has been approved in the target account; otherwise, values over 60 seconds will produce an error at deploy time.
5053
*
5154
* @default Duration.seconds(5)
5255
*/
@@ -62,7 +65,7 @@ export class HttpOrigin extends cloudfront.OriginBase {
6265
super(domainName, props);
6366

6467
validateSecondsInRangeOrUndefined('readTimeout', 1, 180, props.readTimeout);
65-
validateSecondsInRangeOrUndefined('keepaliveTimeout', 1, 60, props.keepaliveTimeout);
68+
validateSecondsInRangeOrUndefined('keepaliveTimeout', 1, 180, props.keepaliveTimeout);
6669
}
6770

6871
protected renderCustomOriginConfig(): cloudfront.CfnDistribution.CustomOriginConfigProperty | undefined {

packages/@aws-cdk/aws-cloudfront-origins/test/http-origin.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ test.each([
8484
Duration.seconds(0),
8585
Duration.seconds(0.5),
8686
Duration.seconds(60.5),
87-
Duration.seconds(61),
87+
Duration.seconds(181),
8888
Duration.minutes(5),
89-
])('validates keepaliveTimeout is an integer between 1 and 60 seconds', (keepaliveTimeout) => {
89+
])('validates keepaliveTimeout is an integer between 1 and 180 seconds', (keepaliveTimeout) => {
9090
expect(() => {
9191
new HttpOrigin('www.example.com', {
9292
keepaliveTimeout,
9393
});
94-
}).toThrow(`keepaliveTimeout: Must be an int between 1 and 60 seconds (inclusive); received ${keepaliveTimeout.toSeconds()}.`);
94+
}).toThrow(`keepaliveTimeout: Must be an int between 1 and 180 seconds (inclusive); received ${keepaliveTimeout.toSeconds()}.`);
9595
});

0 commit comments

Comments
 (0)