Skip to content

Commit

Permalink
fix(DMVP-5400): Cloudfront custom error response
Browse files Browse the repository at this point in the history
  • Loading branch information
Julieta Aghamyan committed Oct 8, 2024
1 parent 873a3fb commit 4914cbe
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/cloudfront/distribution.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ resource "aws_cloudfront_distribution" "main" {
retain_on_delete = var.retain_on_delete
default_root_object = var.default_root_object

dynamic "custom_error_response" {
for_each = var.custom_error_response.enabled ? [1] : []
content {
error_caching_min_ttl = var.custom_error_response.error_caching_min_ttl
error_code = var.custom_error_response.error_code
response_code = var.custom_error_response.response_code
response_page_path = var.custom_error_response.response_page_path
}
}

tags = {
Name = var.tags_name
}
Expand Down
18 changes: 18 additions & 0 deletions modules/cloudfront/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,21 @@ variable "create_response_headers_policy" {
}
description = "Create cloudfront custom header policy"
}

variable "custom_error_response" {
type = object({
enabled = optional(bool, false)
error_caching_min_ttl = optional(number, 10)
error_code = optional(number, 404)
response_code = optional(number, 200)
response_page_path = optional(string, "/index.html")
})
default = {
enabled = false
error_caching_min_ttl = 10
error_code = 404
response_code = 200
response_page_path = "/index.html"
}
description = "Cloudfront custom error response"
}

0 comments on commit 4914cbe

Please sign in to comment.