Skip to content

Commit 8fbb0ac

Browse files
author
Christopher Russell
committed
fix: only create origin_shield block when explicitly enabled
Previously the dynamic block was created whenever origin_shield config existed, even with enabled=false. Now only creates the block when enabled=true, preventing unnecessary resource updates.
1 parent 2c4ae23 commit 8fbb0ac

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ resource "aws_cloudfront_distribution" "this" {
119119
}
120120

121121
dynamic "origin_shield" {
122-
for_each = length(keys(lookup(origin.value, "origin_shield", {}))) == 0 ? [] : [lookup(origin.value, "origin_shield", {})]
122+
for_each = lookup(lookup(origin.value, "origin_shield", {}), "enabled", false) ? [lookup(origin.value, "origin_shield", {})] : []
123123

124124
content {
125125
enabled = origin_shield.value.enabled

0 commit comments

Comments
 (0)