Skip to content

cloudfront-origins: readTimeout cannot exceed 180s even after an origin response timeout quota increase #38433

Description

@mekza

Describe the bug

readTimeout on HttpOrigin, VpcOrigin, FunctionUrlOrigin and RestApiOrigin is validated against a hardcoded upper bound of 180 seconds:

validateSecondsInRangeOrUndefined('readTimeout', 1, 180, props.readTimeout);

It maps to the CloudFront origin response timeout, which is an adjustable service quota. Once a limit increase is approved for an account, CloudFront accepts values above 180 seconds — but the L2 construct rejects them at synth time, so there is no way to express a valid configuration.

This is inconsistent with the construct's own documented behaviour for this same property, which already defers enforcement of the quota to the service:

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.

So values between 61 and 180 are already left to the service to validate, while values above 180 are blocked client-side.

Regression?

No

Last known working version

N/A — the bound has been present since the property was introduced.

Expected Behavior

readTimeout above 180 seconds should synth successfully, and CloudFront should reject it at deploy time if the account's quota has not been raised — the same way values above 60 seconds behave today.

Current Behavior

Synth fails with:

«InvalidDurationRange» readTimeout: Must be an int between 1 and 180 seconds (inclusive); received 300.

Reproduction Steps

new cloudfront.Distribution(this, 'Distribution', {
  defaultBehavior: {
    origin: new origins.HttpOrigin('example.origin.internal', {
      readTimeout: Duration.seconds(300),
    }),
  },
});

Fails at synth, before any call to CloudFront.

For contrast, setting the same value directly on the service succeeds on a distribution whose quota has been raised. Note that CloudFront also constrains the product of ConnectionAttempts × (ConnectionTimeout + OriginReadTimeout), so a high readTimeout may additionally require lowering connectionAttempts; with connectionAttempts: 1 a 300 second readTimeout is accepted:

An error occurred (InvalidArgument) when calling the UpdateDistribution operation:
When your OriginReadTimeout value exceeds the maximum permitted value, ConnectionAttempts must not be set too high.

Possible Solution

Drop the hardcoded upper bound for readTimeout and let the service validate it, keeping the 1 second minimum and the whole-number-of-seconds check.

Additional Information/Context

This matters for long-running streaming origins. In our case a Bedrock AgentCore MCP endpoint behind CloudFront can legitimately take several minutes to respond, and with a 180 second cap the client receives a 504 while the origin is still working.

CDK CLI Version

2.248.0

Framework Version

aws-cdk-lib 2.248.0

Node.js Version

20.x

OS

macOS

Language

TypeScript

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-cloudfront-originsRelated to CloudFront Origins for the CDK CloudFront Libraryeffort/smallSmall work item – less than a day of effortp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions