Skip to content

Commit ce35c50

Browse files
authored
fix: Fixed bug when custom_error_response is empty (#91)
1 parent 2fd7f3f commit ce35c50

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

examples/complete/main.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,13 @@ module "cloudfront" {
140140
ssl_support_method = "sni-only"
141141
}
142142

143-
custom_error_response = {
143+
custom_error_response = [{
144144
error_code = 404
145145
response_page_path = "/errors/404.html"
146-
}
146+
}, {
147+
error_code = 403
148+
response_page_path = "/errors/403.html"
149+
}]
147150

148151
geo_restriction = {
149152
restriction_type = "whitelist"

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ resource "aws_cloudfront_distribution" "this" {
246246
}
247247

248248
dynamic "custom_error_response" {
249-
for_each = flatten([var.custom_error_response])
249+
for_each = length(flatten([var.custom_error_response])[0]) > 0 ? flatten([var.custom_error_response]) : []
250250

251251
content {
252252
error_code = custom_error_response.value["error_code"]

0 commit comments

Comments
 (0)