Last active
August 19, 2019 14:26
-
-
Save arehmandev/d7543db629988dad84c70953095b8eca to your computer and use it in GitHub Desktop.
terraform aliases
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
function tfinit () { | |
if [ -z "${1}" ]; then | |
terraform init | |
else | |
terraform init -backend-config=${1} | |
fi | |
} | |
function tfplan () { | |
if [ -z "${1}" ]; then | |
terraform plan | |
else | |
plan_file=$(echo ${1} | cut -d '/' -f2 | cut -d '.' -f1) | |
rm -rf /tmp/${plan_file}.tfplan | |
terraform plan -out=/tmp/${plan_file}.tfplan -var-file=${1} -input=false | |
fi | |
} | |
function tfapply () { | |
if [ -z "${1}" ]; then | |
terraform apply | |
else | |
plan_file=$(echo ${1} | cut -d '/' -f2 | cut -d '.' -f1) | |
ls /tmp/${plan_file}.tfplan || echo "No tfplan for ${plan_file}" | |
terraform apply -input=false /tmp/${plan_file}.tfplan | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment