Created
September 28, 2018 04:33
-
-
Save srkiNZ84/7ec17402a46c72e6649db49243441875 to your computer and use it in GitHub Desktop.
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 | |
declare -a ENVS_TO_PLAN=(test sandbox production) | |
for i in "${ENVS_TO_PLAN[@]}"; do | |
echo Planning environment: $i | |
cd $i | |
ls -al | |
echo Running Init for $i environment | |
aws-vault exec ident -- terraform init | |
echo Running Plan for $i environment | |
aws-vault exec ident -- terraform plan -no-color -out plan.out > $i-plan-output.txt | |
# Get rid of all contents before "------" line | |
echo Getting Raw TF into variable | |
RAWTF=`cat $i-plan-output.txt` | |
echo Sanitising TF to just get output | |
TFPLAN=${RAWTF#*------------------------------------------------------------------------} | |
echo Outputting plan to file for pasting | |
echo "$TFPLAN" > $i-plan.txt | |
# TODO Post to Slack | |
cd .. | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment