Skip to content
v2.274.0

ErrorResponse Struct ​

Options for configuring custom error responses.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_cloudfront as cloudfront } from 'aws-cdk-lib';
const errorResponse: cloudfront.ErrorResponse = {
  httpStatus: 123,

  // the properties below are optional
  responseHttpStatus: 123,
  responsePagePath: 'responsePagePath',
  ttl: cdk.Duration.minutes(30),
};

Properties ​

httpStatusnumberhttp_statusint | floathttpStatusNumberHttpStatusdoubleHttpStatus*float64required#
The HTTP status code for which you want to specify a custom error page and/or a caching duration.
responseHttpStatusoptionalnumberresponse_http_statusoptionalint | floatresponseHttpStatusoptionalNumberResponseHttpStatusoptionaldoubleResponseHttpStatusoptional*float64#
The HTTP status code that you want CloudFront to return to the viewer along with the custom error page.

Default: the error code will be returned as the response code.

If you specify a value for responseHttpStatus, you must also specify a value for responsePagePath.

responsePagePathoptionalstringresponse_page_pathoptionalstrresponsePagePathoptionalStringResponsePagePathoptionalstringResponsePagePathoptional*string#
The path to the custom error page that you want CloudFront to return to a viewer when your origin returns the `httpStatus`, for example, /4xx-errors/403-forbidden.html.

Default: the default CloudFront response is shown.

ttloptionalDurationttloptionalDurationttloptionalDurationTtloptionalDurationTtloptionalDuration#
The minimum amount of time, in seconds, that you want CloudFront to cache the HTTP status code specified in ErrorCode.

Default: the default caching TTL behavior applies