Last active
November 9, 2017 08:42
-
-
Save danisla/537b84ff902aea3a98dd4f7a010d56e4 to your computer and use it in GitHub Desktop.
Terraform with Docker for Linux, OSX and Google Cloud Shell
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 terraform() | |
{ | |
if [[ -e ${HOME}/.config/gcloud/credentials.json ]]; then | |
GOOGLE_CREDENTIALS="$(cat ${HOME}/.config/gcloud/credentials.json | tr '\n' ' ')"; | |
fi; | |
GOOGLE_PROJECT=${DEVSHELL_PROJECT_ID:-$(gcloud config get-value project 2>/dev/null)}; | |
VERSION=latest | |
docker run -u "${UID}:${UID}" -it --rm -v ${HOME}:${HOME} --env-file <(env|awk '/^.+=/'|grep -v TMPDIR) -e GOOGLE_CREDENTIALS="${GOOGLE_CREDENTIALS}" -e GOOGLE_PROJECT="${GOOGLE_PROJECT}" -w $PWD hashicorp/terraform:${VERSION} $@ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment