Last active
September 27, 2017 03:15
-
-
Save pocheptsov/55e3bb9e6709d72754a4938cb38470ba to your computer and use it in GitHub Desktop.
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 | |
| terraform_upgrade() { | |
| OS_NAME="darwin" | |
| if [[ "$OSTYPE" == "linux"* ]]; then | |
| OS_NAME="linux" | |
| fi | |
| TEMP_PATH="/tmp" | |
| VERSION=$(terraform -v | tail -1 | sed -E 's/.*is ([0-9\.]+)\. .*$/\1/g') \ | |
| && TERRAFORM_ARCHIVE_PATH="$TEMP_PATH/terraform_${VERSION}_${OS_NAME}_amd64.zip" \ | |
| && wget -P "$TEMP_PATH" "https://releases.hashicorp.com/terraform/$VERSION/terraform_${VERSION}_${OS_NAME}_amd64.zip" \ | |
| && sudo unzip -o "$TERRAFORM_ARCHIVE_PATH" -d "$(dirname "$(which terraform)")" \ | |
| && rm "$TERRAFORM_ARCHIVE_PATH" \ | |
| && echo "Terraform upgraded to $VERSION version" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment