Skip to content

Commit f172b67

Browse files
Copilotlgallard
andcommitted
Fix null value handling in dynamic blocks for conditions and selection_tags
Co-authored-by: lgallard <6194359+lgallard@users.noreply.github.com>
1 parent 345ae10 commit f172b67

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

selection.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ resource "aws_backup_selection" "ab_selections" {
104104
not_resources = try(each.value.not_resources, [])
105105

106106
dynamic "condition" {
107-
for_each = length(try(each.value["conditions"], {})) > 0 ? { "conditions" : each.value["conditions"] } : {}
107+
for_each = length(coalesce(try(each.value["conditions"], null), {})) > 0 ? { "conditions" : each.value["conditions"] } : {}
108108
content {
109109
dynamic "string_equals" {
110110
for_each = try(condition.value["string_equals"], {})
@@ -138,7 +138,7 @@ resource "aws_backup_selection" "ab_selections" {
138138
}
139139

140140
dynamic "selection_tag" {
141-
for_each = try(each.value.selection_tags, [])
141+
for_each = coalesce(try(each.value.selection_tags, null), [])
142142
content {
143143
type = try(selection_tag.value.type, null)
144144
key = try(selection_tag.value.key, null)
@@ -168,7 +168,7 @@ resource "aws_backup_selection" "plan_selections" {
168168
not_resources = try(each.value.selection.not_resources, [])
169169

170170
dynamic "condition" {
171-
for_each = length(try(each.value.selection["conditions"], {})) > 0 ? { "conditions" : each.value.selection["conditions"] } : {}
171+
for_each = length(coalesce(try(each.value.selection["conditions"], null), {})) > 0 ? { "conditions" : each.value.selection["conditions"] } : {}
172172
content {
173173
dynamic "string_equals" {
174174
for_each = try(condition.value["string_equals"], {})
@@ -202,7 +202,7 @@ resource "aws_backup_selection" "plan_selections" {
202202
}
203203

204204
dynamic "selection_tag" {
205-
for_each = try(each.value.selection.selection_tags, [])
205+
for_each = coalesce(try(each.value.selection.selection_tags, null), [])
206206
content {
207207
type = try(selection_tag.value.type, null)
208208
key = try(selection_tag.value.key, null)

0 commit comments

Comments
 (0)