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:
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 can then take the above grep'd
output and paste it into a Text Editor and match up the names for easy state move commands.
No requirements.
No provider.
Name | Description | Type | Default | Required |
---|---|---|---|---|
map | A map of resource names and element names | map(string) |
n/a | yes |
replace | A map of information for string replacement | map(object({ |
n/a | yes |
Name | Description |
---|---|
map | A map to use in a for_each loop |