Created
October 29, 2016 04:49
-
-
Save jamtur01/bcf0f0aefe20e8078898cbd27f121b5b to your computer and use it in GitHub Desktop.
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 | |
type terraform >/dev/null 2>&1 || { echo >&2 "I require terraform but it's not installed. Quitting sadly."; exit 1; } | |
REGION="us-east-1" | |
BUCKET="remote_state" | |
ENVIRONMENT=${PWD##*/} | |
STATE_FILE="terraform.tfstate" | |
ARGS=$* | |
remote() { | |
terraform remote config \ | |
-backend=s3 \ | |
-backend-config="region=${REGION}" \ | |
-backend-config="bucket=${BUCKET}-${ENVIRONMENT}" \ | |
-backend-config="key=${STATE_FILE}" | |
} | |
run() { | |
terraform $ARGS | |
} | |
if ! terraform remote pull; then | |
remote | |
fi | |
run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment