Created
July 14, 2021 13:45
-
-
Save jordiclariana/f9055ca41ca53efbce796c939ae1f9cc to your computer and use it in GitHub Desktop.
Run Terraform plan or get a plan output, show only resources names to be changed and color the relevant parts
This file contains 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 | |
set -e | |
if [ $# -eq 0 ]; then | |
plan_file=$(mktemp) | |
terraform plan -no-color > "$plan_file" | |
else | |
if [ ! -e "$1" ]; then | |
echo "File '$1' does not exist. Aborting" | |
exit 1 | |
fi | |
plan_file="$1" | |
fi | |
echo "# Plan file: $plan_file" | |
ag "^ #.* will be" "$plan_file" | \ | |
sed -r 's/^[0-9]+: *# //' | \ | |
sed 's/updated/\x1B[93mupdated\x1B[0m/g;s/destroyed/\x1B[91mdestroyed\x1B[0m/g;s/created/\x1B[92mcreated\x1B[0m/g;s/read/\x1B[1mread\x1B[0m/g' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment