Skip to content

Commit

Permalink
Add purpose to README
Browse files Browse the repository at this point in the history
  • Loading branch information
benniemosher committed Jun 29, 2020
1 parent 2d485d3 commit 63dd29d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# nested_maps
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 with`for_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 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.

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements
Expand Down

0 comments on commit 63dd29d

Please sign in to comment.