Last active
May 5, 2020 12:14
-
-
Save wagnst/64640827eb54ed1bb7334a216c5c1ce7 to your computer and use it in GitHub Desktop.
Switch terraform version via bash
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
#Terraform version switch | |
function terraformv() { | |
if [ $# -eq 1 ]; then | |
if test -f "/opt/terraform/terraform-${1}"; then | |
sudo rm /opt/terraform/terraform | |
sudo ln -s "/opt/terraform/terraform-${1}" /opt/terraform/terraform | |
echo "switched to terraform-${1}" | |
else | |
echo "terraform-${1} does not exist, pls download from https://releases.hashicorp.com/terraform/ first and store in /opt/terraform." | |
return 1 | |
fi | |
fi | |
} | |
alias tfv='terraformv' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage example:
or