Skip to content

Instantly share code, notes, and snippets.

@josh-padnick
Created April 25, 2016 20:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save josh-padnick/3a154b6366b2b18686667a210b227bb4 to your computer and use it in GitHub Desktop.
Save josh-padnick/3a154b6366b2b18686667a210b227bb4 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# If there's a new Terraform releases available, delete the current Terraform install and download the new one.
# Must be run from within the directory where terraform binaries should reside
#
LATEST_RELEASE=$(curl https://api.github.com/repos/hashicorp/terraform/releases/latest | jq --raw-output '.tag_name' | cut -c 2-)
if [[ ! -e ${LATEST_RELEASE} ]]; then
echo "Installing Terraform ${LATEST_RELEASE}..."
rm terraform-*
rm terraform
wget https://releases.hashicorp.com/terraform/${LATEST_RELEASE}/terraform_${LATEST_RELEASE}_darwin_amd64.zip
unzip terraform_${LATEST_RELEASE}_darwin_amd64.zip
rm terraform_${LATEST_RELEASE}_darwin_amd64.zip
touch ${LATEST_RELEASE}
else
echo "Latest Terraform already installed."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment