Command line
Use dropdown menu to select version
- You can switch between different versions of terraform by typing the command
tfswitch
on your terminal. - Select the version of terraform you require by using the up and down arrow.
- Hit Enter to select the desired version.
The most recently selected versions are presented at the top of the dropdown.
Supply version on command line
- You can also supply the desired version as an argument on the command line.
- For example,
tfswitch 0.10.5
for version 0.10.5 of terraform. - Hit Enter to switch.
See all versions including beta, alpha and release candidates(rc)
- Display all versions including beta, alpha and release candidates(rc).
- For example,
tfswitch -l
ortfswitch --list-all
to see all versions. - Hit Enter to select the desired version.
Use environment variables
You can also set the TF_VERSION
environment variable to your desired terraform version. For example:
export TF_VERSION=0.14.4
tfswitch #will automatically switch to terraform version 0.14.4
Install latest version only
- Install the latest stable version only.
- Run
tfswitch -u
ortfswitch --latest
. - Hit Enter to install.
Install latest implicit version for stable releases
- Install the latest implicit stable version.
- Ex:
tfswitch -s 0.13
ortfswitch --latest-stable 0.13
downloads 0.13.6 (latest) version. - Hit Enter to install.
Install latest implicit version for beta, alpha and release candidates(rc)
- Install the latest implicit pre-release version.
- Ex:
tfswitch -p 0.13
ortfswitch --latest-pre 0.13
downloads 0.13.0-rc1 (latest) version. - Hit Enter to install.
Show latest version only
- Just show what the latest version is.
- Run
tfswitch -U
ortfswitch --show-latest
- Hit Enter to show.
Show latest implicit version for stable releases
- Show the latest implicit stable version.
- Ex:
tfswitch -S 0.13
ortfswitch --show-latest-stable 0.13
shows 0.13.6 (latest) version. - Hit Enter to show.
Show latest implicit version for beta, alpha and release candidates(rc)
- Show the latest implicit pre-release version.
- Ex:
tfswitch -P 0.13
ortfswitch --show-latest-pre 0.13
shows 0.13.0-rc1 (latest) version. - Hit Enter to show.
Use custom mirror
To install from a remote mirror other than the default(https://releases.hashicorp.com/terraform). Use the -m
or --mirror
parameter.
tfswitch --mirror https://example.jfrog.io/artifactory/hashicorp`
Install to non-default location
By default tfswitch
will download the Terraform binary to the user home directory under this path: $HOME/.terraform.versions
If you want to install the binaries outside of the home directory then you can provide the -i
or --install
to install Terraform binaries to a non-standard path. Useful if you want to install versions of Terraform that can be shared with multiple users.
The Terraform binaries will then be placed in the directory .terraform.versions
under the custom install path e.g. /opt/terraform/.terraform.versions
tfswitch -i /opt/terraform
NOTE - The directory passed in -i
/--install
must be created before running tfswitch