Skip to content

Commit

Permalink
feat: custom error responses
Browse files Browse the repository at this point in the history
  • Loading branch information
coolapso committed Jun 10, 2024
1 parent 6ecc9af commit 69ad78f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ No modules.
| <a name="input_cloudfront_origin_description"></a> [cloudfront\_origin\_description](#input\_cloudfront\_origin\_description) | Description for the origin | `string` | n/a | yes |
| <a name="input_cloudfront_origin_name"></a> [cloudfront\_origin\_name](#input\_cloudfront\_origin\_name) | The name of the cloudfront origin | `string` | n/a | yes |
| <a name="input_cookies_forward"></a> [cookies\_forward](#input\_cookies\_forward) | cookies forwarding | `string` | `"none"` | no |
| <a name="input_custom_error_responses"></a> [custom\_error\_responses](#input\_custom\_error\_responses) | Custom error response definitions | <pre>list(object({<br> error_caching_min_ttl = optional(number)<br> error_code = optional(number)<br> response_code = optional(number)<br> response_page_path = optional(string)<br> }))</pre> | n/a | yes |
| <a name="input_default_root_object"></a> [default\_root\_object](#input\_default\_root\_object) | The default website root object | `string` | `null` | no |
| <a name="input_default_ttl"></a> [default\_ttl](#input\_default\_ttl) | Default cache ttl | `number` | `1800` | no |
| <a name="input_enable_distribution"></a> [enable\_distribution](#input\_enable\_distribution) | Enables the cf distributuion | `bool` | `true` | no |
Expand Down
11 changes: 11 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ resource "aws_cloudfront_distribution" "this" {
max_ttl = var.max_ttl
}

dynamic "custom_error_response" {
for_each = var.custom_error_responses

content {
error_caching_min_ttl = var.custom_error_responses[custom_error_response.key].error_caching_min_ttl
error_code = var.custom_error_responses[custom_error_response.key].error_code
response_code = var.custom_error_responses[custom_error_response.key].response_code
response_page_path = var.custom_error_responses[custom_error_response.key].response_page_path
}
}


restrictions {
geo_restriction {
Expand Down
10 changes: 10 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ variable "max_ttl" {
default = 3600
}

variable "custom_error_responses" {
description = "Custom error response definitions"
type = list(object({
error_caching_min_ttl = optional(number)
error_code = optional(number)
response_code = optional(number)
response_page_path = optional(string)
}))
}

variable "acm_certificate_arn" {
description = "ACM Certificate ARN, must be us-east-1"
type = string
Expand Down

0 comments on commit 69ad78f

Please sign in to comment.