Skip to content

Instantly share code, notes, and snippets.

@prombouts
Last active August 19, 2021 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prombouts/619f0c8b8d8bacee174fb9c72624dd56 to your computer and use it in GitHub Desktop.
Save prombouts/619f0c8b8d8bacee174fb9c72624dd56 to your computer and use it in GitHub Desktop.
Install or update the latest Terraform binary on your WSL/Linux instance
#!/bin/bash
LATEST_RELEASE=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r .current_version)
CURRENT_RELEASE=$(terraform version -json | jq -r .terraform_version)
if [[ ${LATEST_RELEASE} != $CURRENT_RELEASE ]]; then
echo "Installing Terraform ${LATEST_RELEASE}..."
FILENAME=terraform_${LATEST_RELEASE}_linux_amd64.zip
wget https://releases.hashicorp.com/terraform/${LATEST_RELEASE}/$FILENAME
unzip $FILENAME && rm $FILENAME
sudo mv terraform /usr/local/bin
else
echo "Latest version of Terraform (${LATEST_RELEASE}) already installed."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment