Skip to content

Commit 5de57d3

Browse files
committed
feat(origins): added optional origin_shield section for additional
origins: custom_origins & s3_origins
1 parent 9a65f7e commit 5de57d3

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

main.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,14 @@ resource "aws_cloudfront_distribution" "default" {
570570
origin_keepalive_timeout = lookup(origin.value.custom_origin_config, "origin_keepalive_timeout", 60)
571571
origin_read_timeout = lookup(origin.value.custom_origin_config, "origin_read_timeout", 60)
572572
}
573+
574+
dynamic "origin_shield" {
575+
for_each = origin.value.origin_shield != null ? [origin.value.origin_shield] : []
576+
content {
577+
enabled = origin_shield.value.enabled
578+
origin_shield_region = origin_shield.value.region
579+
}
580+
}
573581
}
574582
}
575583

@@ -589,6 +597,14 @@ resource "aws_cloudfront_distribution" "default" {
589597
origin_access_identity = local.origin_access_identity_enabled && try(length(origin.value.s3_origin_config.origin_access_identity), 0) > 0 ? origin.value.s3_origin_config.origin_access_identity : local.origin_access_identity_enabled ? local.cf_access.path : ""
590598
}
591599
}
600+
601+
dynamic "origin_shield" {
602+
for_each = origin.value.origin_shield != null ? [origin.value.origin_shield] : []
603+
content {
604+
enabled = origin_shield.value.enabled
605+
origin_shield_region = origin_shield.value.region
606+
}
607+
}
592608
}
593609
}
594610

variables.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,10 @@ variable "custom_origins" {
464464
origin_keepalive_timeout = number
465465
origin_read_timeout = number
466466
})
467+
origin_shield = optional(object({
468+
enabled = optional(bool, false)
469+
region = optional(string, null)
470+
}), null)
467471
}))
468472
default = []
469473
description = <<-EOT
@@ -482,6 +486,10 @@ variable "s3_origins" {
482486
s3_origin_config = object({
483487
origin_access_identity = string
484488
})
489+
origin_shield = optional(object({
490+
enabled = optional(bool, false)
491+
region = optional(string, null)
492+
}), null)
485493
}))
486494
default = []
487495
description = <<-EOT

0 commit comments

Comments
 (0)