nested-maps
benniemosher/nested-maps/terraform
A small Terraform module to build a nested map for for_each resource declarations
terraform-nested-maps A small Terraform module to build a nested map to use withfor_each resource declarations. I wanted to condence 100+ lines of remote data sources to pull in resources, and I wanted to utilize the new for_each feature. This could easily go in one file and not be a module, but this allows me to use the same method for things like vpc_peering_connections. I wanted to use this module method because it now gives me really neat names like aws_security_group.this['cms-dev']. This makes it pretty easy to move and refactor these as they still have the same name: ``bash tf plan > plan.tfplan cat plan.tfplan | grep "destroyed" # creates output like data.aws_security_group.cms-dev cat plan.tfplan | grep "created" # creates output like data.aws_security_group.this["cms-dev"] ` You
| Name | Type | Description | Default |
|---|---|---|---|
| map | map(string) | A map of resource names and element names | required |
| replace | map(object({ string_find | A map of information for string replacement | required |
map — A map to use in a for_each loop