Skip to content

Commit

Permalink
feat(cloudfront-origins): extend max keepaliveTimeout of HttpOrigin t…
Browse files Browse the repository at this point in the history
…o 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*
  • Loading branch information
taeemo committed Feb 21, 2022
1 parent b2bba77 commit 171fdcd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-cloudfront-origins/README.md
Expand Up @@ -76,11 +76,12 @@ const origin = new origins.LoadBalancerV2Origin(loadBalancer, {
connectionAttempts: 3,
connectionTimeout: Duration.seconds(5),
readTimeout: Duration.seconds(45),
keepaliveTimeout: Duration.seconds(45),
protocolPolicy: cloudfront.OriginProtocolPolicy.MATCH_VIEWER,
});
```

Note that the `readTimeout` property can extend its value over 60 seconds only if a limit increase request for CloudFront origin response timeout
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
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
still limited to a maximum value of 180 seconds, which is a hard limit for that quota.

Expand Down
7 changes: 5 additions & 2 deletions packages/@aws-cdk/aws-cloudfront-origins/lib/http-origin.ts
Expand Up @@ -46,7 +46,10 @@ export interface HttpOriginProps extends cloudfront.OriginProps {

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

validateSecondsInRangeOrUndefined('readTimeout', 1, 180, props.readTimeout);
validateSecondsInRangeOrUndefined('keepaliveTimeout', 1, 60, props.keepaliveTimeout);
validateSecondsInRangeOrUndefined('keepaliveTimeout', 1, 180, props.keepaliveTimeout);
}

protected renderCustomOriginConfig(): cloudfront.CfnDistribution.CustomOriginConfigProperty | undefined {
Expand Down
Expand Up @@ -84,12 +84,12 @@ test.each([
Duration.seconds(0),
Duration.seconds(0.5),
Duration.seconds(60.5),
Duration.seconds(61),
Duration.seconds(181),
Duration.minutes(5),
])('validates keepaliveTimeout is an integer between 1 and 60 seconds', (keepaliveTimeout) => {
])('validates keepaliveTimeout is an integer between 1 and 180 seconds', (keepaliveTimeout) => {
expect(() => {
new HttpOrigin('www.example.com', {
keepaliveTimeout,
});
}).toThrow(`keepaliveTimeout: Must be an int between 1 and 60 seconds (inclusive); received ${keepaliveTimeout.toSeconds()}.`);
}).toThrow(`keepaliveTimeout: Must be an int between 1 and 180 seconds (inclusive); received ${keepaliveTimeout.toSeconds()}.`);
});

0 comments on commit 171fdcd

Please sign in to comment.