Last active
August 15, 2020 05:39
-
-
Save immanuelpotter/3fae4d15150dc5f094ca69454b18d333 to your computer and use it in GitHub Desktop.
If you only want to perform actions on resources in one terraform file, this will do that for you
This file contains hidden or 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
| #!/bin/bash | |
| COMMAND="$1" | |
| TF_FILE="$2" | |
| usage(){ | |
| echo "Usage: $0 (plan|apply|destroy) [tf-filename]" | |
| } | |
| main(){ | |
| if [[ -z $COMMAND || -z $TF_FILE ]] ; then | |
| usage | |
| else | |
| for i in $(awk '/resource/{print $2,$3}' $TF_FILE | tr -d '"' | tr ' ' '.') ; do $(which terraform) $COMMAND -target="${i}" ; done | |
| fi | |
| } | |
| main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment