Skip to content

Commit e64de67

Browse files
authored
feat(cloudfront-origins): extend readTimeout maximum value for HttpOriginProps (#18697)
This pull request extends the maximum value of the `readTimeout` 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 request timeout quota](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html#limits-web-distributions). The 180 seconds cap should be AWS hard limit for that quota. Closes #18628 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 9de9bfe commit e64de67

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

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

+5
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,15 @@ declare const loadBalancer: elbv2.ApplicationLoadBalancer;
7575
const origin = new origins.LoadBalancerV2Origin(loadBalancer, {
7676
connectionAttempts: 3,
7777
connectionTimeout: Duration.seconds(5),
78+
readTimeout: Duration.seconds(45),
7879
protocolPolicy: cloudfront.OriginProtocolPolicy.MATCH_VIEWER,
7980
});
8081
```
8182

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+
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
85+
still limited to a maximum value of 180 seconds, which is a hard limit for that quota.
86+
8287
## From an HTTP endpoint
8388

8489
Origins can also be created from any other HTTP endpoint, given the domain name, and optionally, other origin properties.

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

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

3636
/**
3737
* Specifies how long, in seconds, CloudFront waits for a response from the origin, also known as the origin response timeout.
38-
* The valid range is from 1 to 60 seconds, inclusive.
38+
* The valid range is from 1 to 180 seconds, inclusive.
39+
*
40+
* Note that values over 60 seconds are possible only after a limit increase request for the origin response timeout quota
41+
* has been approved in the target account; otherwise, values over 60 seconds will produce an error at deploy time.
3942
*
4043
* @default Duration.seconds(30)
4144
*/
@@ -58,7 +61,7 @@ export class HttpOrigin extends cloudfront.OriginBase {
5861
constructor(domainName: string, private readonly props: HttpOriginProps = {}) {
5962
super(domainName, props);
6063

61-
validateSecondsInRangeOrUndefined('readTimeout', 1, 60, props.readTimeout);
64+
validateSecondsInRangeOrUndefined('readTimeout', 1, 180, props.readTimeout);
6265
validateSecondsInRangeOrUndefined('keepaliveTimeout', 1, 60, props.keepaliveTimeout);
6366
}
6467

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ test.each([
7070
Duration.seconds(0),
7171
Duration.seconds(0.5),
7272
Duration.seconds(60.5),
73-
Duration.seconds(61),
73+
Duration.seconds(181),
7474
Duration.minutes(5),
75-
])('validates readTimeout is an integer between 1 and 60 seconds', (readTimeout) => {
75+
])('validates readTimeout is an integer between 1 and 180 seconds', (readTimeout) => {
7676
expect(() => {
7777
new HttpOrigin('www.example.com', {
7878
readTimeout,
7979
});
80-
}).toThrow(`readTimeout: Must be an int between 1 and 60 seconds (inclusive); received ${readTimeout.toSeconds()}.`);
80+
}).toThrow(`readTimeout: Must be an int between 1 and 180 seconds (inclusive); received ${readTimeout.toSeconds()}.`);
8181
});
8282

8383
test.each([

0 commit comments

Comments
 (0)