Last active
March 29, 2019 01:13
-
-
Save jayers99/31f45ecc3930632e5d983cd70f672a76 to your computer and use it in GitHub Desktop.
terraform plan policy differences
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
# final final | |
string=$(cat sample.txt | grep -P '^\s+policy:' | sed -r 's/\s*policy:\s*//g; s/\\n//g; s/\\\"/"/g; s/\s+//g; s/=>/\n/g') | |
IFS=$'\n' GLOBIGNORE='*' command eval 'array=($string)' | |
diff <(echo ${array[0]} | sed -e 's/^"//g' -e 's/"$//g' | jq -S '.') <(echo ${array[1]} | sed -e 's/^"//g' -e 's/"$//g' | jq -S '.') | grep -v "^[0-9c0-9]" | |
# sed file | |
s/\s*policy:\s*//g | |
s/\\n//g | |
s/\\\"/"/g | |
s/\s+//g | |
s/=>/\n/g | |
string=$(cat sample.txt | grep -P '^\s+policy:' | sed -r -f policy.sed) | |
IFS=$'\n' GLOBIGNORE='*' command eval 'array=($string)' | |
diff <(echo ${array[0]} | sed -e 's/^"//g' -e 's/"$//g' | jq -S '.') <(echo ${array[1]} | sed -e 's/^"//g' -e 's/"$//g' | jq -S '.') | |
# some old steps along the way | |
cat sample.txt | grep -P '^\s+policy:' | sed -r 's/\s*policy:\s*//g' | |
string=$(cat sample.txt | grep -P '^\s+policy:' | sed -r 's/\s*policy:\s*//g' | sed -r 's/\\n//g' | sed -r 's/\\\"/"/g' | sed -r 's/\s+//g' | sed -r 's/=>/\n/g') | |
IFS=$'\n' GLOBIGNORE='*' command eval 'array=($string)' | |
diff <(echo ${array[0]} | sed -e 's/^"//g' -e 's/"$//g' | jq -S '.') <(echo ${array[1]} | sed -e 's/^"//g' -e 's/"$//g' | jq -S '.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment