Skip to content

Instantly share code, notes, and snippets.

@arehmandev
Last active August 19, 2019 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arehmandev/d7543db629988dad84c70953095b8eca to your computer and use it in GitHub Desktop.
Save arehmandev/d7543db629988dad84c70953095b8eca to your computer and use it in GitHub Desktop.
terraform aliases
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