Skip to content

Instantly share code, notes, and snippets.

@tdlmatias
Created December 20, 2019 11:02
Show Gist options
  • Save tdlmatias/902ddca6f2fda9bac17e5fd73a8f7b22 to your computer and use it in GitHub Desktop.
Save tdlmatias/902ddca6f2fda9bac17e5fd73a8f7b22 to your computer and use it in GitHub Desktop.
#!/bin/bash
function terraform-install() {
[[ -f ${HOME}/bin/terraform ]] && echo "`${HOME}/bin/terraform version` already installed at ${HOME}/bin/terraform" && return 0
LATEST_URL=$(curl -sL https://releases.hashicorp.com/terraform/index.json | jq -r '.versions[].builds[].url' | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | egrep -v 'rc|beta' | egrep 'linux.*amd64' |tail -1)
curl ${LATEST_URL} > /tmp/terraform.zip
mkdir -p ${HOME}/bin
(cd ${HOME}/bin && unzip /tmp/terraform.zip)
if [[ -z $(grep 'export PATH=${HOME}/bin:${PATH}' ~/.bashrc) ]]; then
echo 'export PATH=${HOME}/bin:${PATH}' >> ~/.bashrc
fi
echo "Installed: `${HOME}/bin/terraform version`"
cat - << EOF
Run the following to reload your PATH with terraform:
source ~/.bashrc
EOF
}
terraform-install
@tdlmatias
Copy link
Author

This is script allows you to install Terraform - just test it before use it ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment