# ErrorResponse

Options for configuring custom error responses.

- Source: [`aws-cloudfront/lib/distribution.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts#L1050)

## Example

TypeScript:

```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),
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_cloudfront as cloudfront

error_response = cloudfront.ErrorResponse(
    http_status=123,

    # the properties below are optional
    response_http_status=123,
    response_page_path="responsePagePath",
    ttl=cdk.Duration.minutes(30)
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.cloudfront.*;

ErrorResponse errorResponse = ErrorResponse.builder()
        .httpStatus(123)

        // the properties below are optional
        .responseHttpStatus(123)
        .responsePagePath("responsePagePath")
        .ttl(Duration.minutes(30))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.CloudFront;

var errorResponse = new ErrorResponse {
    HttpStatus = 123,

    // the properties below are optional
    ResponseHttpStatus = 123,
    ResponsePagePath = "responsePagePath",
    Ttl = Duration.Minutes(30)
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

errorResponse := &ErrorResponse{
	HttpStatus: jsii.Number(123),

	// the properties below are optional
	ResponseHttpStatus: jsii.Number(123),
	ResponsePagePath: jsii.String("responsePagePath"),
	Ttl: cdk.Duration_Minutes(jsii.Number(30)),
}
```

## Properties

- `httpStatus`: number (required) — The HTTP status code for which you want to specify a custom error page and/or a caching duration.

- `responseHttpStatus`: number — 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`.

- `responsePagePath`: 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.

- `ttl`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — 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
