Last active
July 5, 2018 18:01
-
-
Save jwieringa/090841f6a699a7b6628b24f5542a74f0 to your computer and use it in GitHub Desktop.
A helper bash script for selectively applying Terraform resources
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 | |
plan () { | |
terraform plan \ | |
-out=plan.output \ | |
-target=module.useast1.aws_eip.nateip[3] | |
} | |
apply () { | |
terraform apply plan.output | |
} | |
usage () { | |
echo "Usage: file-sync [-s FILE] [-l FILE]" | |
echo " -h Help. Display this message and quit." | |
echo " -p Create Terraform plan in az-plan" | |
echo " -a Apply plan file" | |
} | |
[ $# -eq 0 ] && usage | |
while getopts ":pah" opt; do | |
case "${opt}" in | |
p) | |
plan | |
;; | |
a) | |
apply | |
;; | |
\?) | |
echo "Invalid option: -$OPTARG" >&2 | |
exit 1 | |
;; | |
:) | |
echo "Option -$OPTARG requires an argument." >&2 | |
exit 1 | |
;; | |
h | *) | |
usage | |
exit 0 | |
;; | |
esac | |
done | |
shift $((OPTIND -1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment