Skip to content

Instantly share code, notes, and snippets.

@kesonno
Forked from josh-padnick/get-latest-terraform.sh
Created September 29, 2017 07:31
Show Gist options
  • Save kesonno/55a28422d35c1c2caeebfa444ee76f86 to your computer and use it in GitHub Desktop.
Save kesonno/55a28422d35c1c2caeebfa444ee76f86 to your computer and use it in GitHub Desktop.
Auto-update to latest version of Terraform
#!/bin/bash
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}_linux_amd64.zip
unzip terraform_${LATEST_RELEASE}_linux_amd64.zip
rm terraform_${LATEST_RELEASE}_linux_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