Last active
July 9, 2024 17:00
-
-
Save prombouts/619f0c8b8d8bacee174fb9c72624dd56 to your computer and use it in GitHub Desktop.
Install or update the latest Terraform binary on your WSL/Linux instance
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
#!/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