Skip to content

Instantly share code, notes, and snippets.

@gcormier
Last active May 28, 2020 14:03
Show Gist options
  • Save gcormier/e9fbd78ffb22bc8be78fe6bfae8edc98 to your computer and use it in GitHub Desktop.
Save gcormier/e9fbd78ffb22bc8be78fe6bfae8edc98 to your computer and use it in GitHub Desktop.
Update terraform and packer
#!/bin/bash
echo "Updating terraform..."
LATEST_URL=$(curl https://releases.hashicorp.com/terraform/index.json --silent | jq -r '.versions[].builds[].url' | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n | egrep -v 'rc|beta' | egrep 'linux.*amd64' |tail -1)
wget -O tf.zip $LATEST_URL --quiet
sudo unzip -o -q tf.zip -d /usr/local/bin
rm tf.zip
echo "Updated /usr/local/bin/terraform to version `terraform version`"
echo "Updating packer..."
LATEST_URL=$(curl https://releases.hashicorp.com/packer/index.json --silent | jq -r '.versions[].builds[].url' | sort -t. -k 1,1n -k 2,2n -k 3,3n | egrep -v 'rc|beta' | egrep 'linux.*amd64' |tail -1)
echo $LATEST_URL
wget -O packer.zip $LATEST_URL --quiet
sudo unzip -o -q packer.zip -d /usr/local/bin
rm packer.zip
echo "Updated /usr/local/bin/packer to version `packer version`"
echo "Updating azcopy..."
wget https://aka.ms/downloadazcopy-v10-linux --quiet
tar -xvf downloadazcopy-v10-linux
sudo rm /usr/local/bin/azcopy
sudo cp ./azcopy_linux_amd64_*/azcopy /usr/local/bin/azcopy
sudo chmod 755 /usr/local/bin/azcopy
rm -r ./azcopy_linux_amd64*
echo "Updated /usr/local/bin/azcopy to version `azcopy --version`"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment