Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change acl for_each conditional to fix bug #725

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion network_acls.tf
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ locals {
}

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