Skip to content

Instantly share code, notes, and snippets.

@ringanta
Created July 14, 2020 07:17
Show Gist options
  • Save ringanta/f33833b090d5102ad6730a574d9537b9 to your computer and use it in GitHub Desktop.
Save ringanta/f33833b090d5102ad6730a574d9537b9 to your computer and use it in GitHub Desktop.
set -e
TEMP_SETUP_DIR=$(mktemp -d)
TF_PROJECT=.deployment/terraform/trident/ap-southeast-1/${ENVIRONMENT}-${MODE}
function cleanup {
rm -fr $TEMP_SETUP_DIR tfplan.out
}
trap cleanup EXIT
apt-get update && apt-get -y install git curl
pushd $TEMP_SETUP_DIR
# Setup tfenv to install terraform version based on required_version setting in tf script
git clone https://github.com/tfutils/tfenv.git .
export PATH=$TEMP_SETUP_DIR/bin:$PATH
popd
pushd $TF_PROJECT
rm -rf .terraform
tfenv install min-required
tfenv use min-required
terraform init
terraform plan -out=tfplan.out
terraform apply tfplan.out
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment