Skip to content

Commit 60867f4

Browse files
authored
fix: change acl for_each conditional to fix bug (#725)
1 parent 87473b8 commit 60867f4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

network_acls.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,11 @@ locals {
160160
}
161161

162162
resource "ibm_is_network_acl" "network_acl" {
163-
for_each = var.create_subnets ? local.acl_object : {}
163+
# due to a bug in terraform ternary conditional and nested map objects, use a for loop with if condition to only apply
164+
# ACLs if subnets are being created (not for existing subnets scenario)
165+
# The old version of this that had the bug was:
166+
# for_each = var.create_subnets ? local.acl_object : {}
167+
for_each = { for acl_key, acl_value in local.acl_object : acl_key => acl_value if var.create_subnets }
164168
name = var.prefix != null ? "${var.prefix}-${each.key}" : each.key #already has name of vpc in each.key
165169
vpc = local.vpc_id
166170
resource_group = var.resource_group_id

0 commit comments

Comments
 (0)