-
-
Save abdrehma/b8a258a085203cd987848c656e32d3bc to your computer and use it in GitHub Desktop.
Terraform nested for loop for_each
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locals { | |
nested_loop = { for entry in flatten(values({ | |
for k, v in var.hub_networks : | |
k => [ | |
for key, val in var.firewalls : | |
merge(val, v, { "key" : "default-deny-${lower(val.direction)}-${v.network}" }) | |
] | |
})) : entry.key => entry } | |
} | |
hub_networks = { | |
int = { | |
project = "int" | |
network = "int-network" | |
} | |
pre = { | |
project = "pre" | |
network = "pre-network" | |
} | |
} | |
firewalls = { | |
deny_egress = { | |
direction = "EGRESS" | |
priority = 65535 | |
} | |
deny_ingress = { | |
direction = "INGRESS" | |
priority = 65534 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment