Skip to content

Commit

Permalink
update docs for custom_error_message
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillip committed Jul 27, 2020
1 parent d78a47f commit b3ccf07
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ supports S3 redirects. This module helps keep setup consistent for multiple Hugo
- `cf_min_ttl` - Minimum CloudFront caching TTL. Default: `0`
- `cf_max_ttl` - Maximum CloudFront caching TTL. Default: `31536000`
- `cf_price_class` - The CloudFront pricing class to use. Default: `PriceClass_All`
- `custom_error_response` - A list of objects to provide custom error responses from CloudFront.
See [Using Custom Error Responses from CloudFront](#using-custom-error-responses-from-cloudfront) for details.
- `default_root_object` - Default root object for CloudFlare to request when not otherwise specified. Default: `index.html`
- `error_document` - The file that should be served for errors. Default: `404.html`
- `index_document` - The default file to be served. Default: `index.html`
- `origin_path` - Path to document root in S3 bucket without slashes. Default: `public`
Expand All @@ -42,6 +45,28 @@ module "hugosite" {
}
```

## Using Custom Error Responses from CloudFront
Cloudfront allows you to override error responses if desired. This is useful when hosting Single Page Apps on S3
and want to leverage the default error document to route all requests to your index, but prevent S3 from returning
a 404 error to the browser. Here is an example of replacing 404 errors with 200 OK responses.

```hcl
module "hugosite" {
source = "github.com/fillup/terraform-hugo-s3-cloudfront"
aliases = ["www.domain.com", "domain.com"]
bucket_name = "www.domain.com"
cert_domain = "*.domain.com"
deployment_user_arn = "arn:aws:iam::111122223333:person"
default_root_object = null
error_document = "index.html"
custom_error_response = set(object({
error_code = 404
response_code = 200
response_page_path = "/index.html"
}))
}
```

## License - MIT
MIT License

Expand Down

0 comments on commit b3ccf07

Please sign in to comment.