Last active
March 23, 2021 07:21
-
-
Save olen2006/9afe9e42cbce30cb399543704410c016 to your computer and use it in GitHub Desktop.
script checks and installs latest version of terraforom
This file contains hidden or 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 -xe | |
CURRENT_VER=$(terraform --version | head -n1 | cut -d " " -f2 | cut -c 2-) | |
LATEST_RELEASE=$(curl -s https://api.github.com/repos/hashicorp/terraform/releases/latest | jq --raw-output '.tag_name' | cut -c 2-) | |
if [[ $CURRENT_VER < $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 | |
mv terraform /usr/local/bin/ | |
echo "Terraforom was updated to the ${LATEST_RELEASE} version" | |
else | |
echo "Current version of terraform" $CURRENT_VER "is up to date" | |
fi | |
#https://learn.hashicorp.com/tutorials/terraform/install-cli | |
#https://computingforgeeks.com/how-to-install-terraform-on-ubuntu-centos-7/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment