diff --git a/examples/terraform-install.sh b/examples/terraform-install.sh index 1db8341..8431b57 100755 --- a/examples/terraform-install.sh +++ b/examples/terraform-install.sh @@ -2,7 +2,9 @@ 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|alpha|beta' | egrep "$(uname | tr '[:upper:]' '[:lower:]').*amd64" |tail -1) + OS=$(uname -s) + LATEST_VERSION=$(curl -sL https://releases.hashicorp.com/terraform/index.json | jq -r '.versions[].version' | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | egrep -v 'alpha|beta|rc' | tail -1) + LATEST_URL="https://releases.hashicorp.com/terraform/${LATEST_VERSION}/terraform_${LATEST_VERSION}_${OS,,}_amd64.zip" curl ${LATEST_URL} > /tmp/terraform.zip mkdir -p ${HOME}/bin (cd ${HOME}/bin && unzip /tmp/terraform.zip)