Skip to content

Instantly share code, notes, and snippets.

@prombouts
Last active July 9, 2024 17:00
Show Gist options
  • 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