Installation and Setup
Here’s a script that installs tfswitch
and uses it to install the latest version of Terraform:
# Install tfswitch
curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash
# Use tfswitch to install latest version of Terraform
tfswitch --latest
tfswitch
is a command-line tool that allows you to switch between different versions of Terraform on your local machine. It makes it easy to install and manage multiple versions of Terraform, and ensures that you are using the correct version of Terraform for your projects.
With tfswitch
, you can install and switch to different versions of Terraform with a single command. It automatically downloads and installs the desired version of Terraform, and updates your PATH
environment variable to point to the new version.
tfswitch
also includes features like auto-updating, version pinning, and version locking to help you manage your Terraform installations more easily. It is available for Windows, macOS, and Linux.
Here’s an example of how you can use tfswitch
to install and switch between different versions of Terraform:
- Install
tfswitch
by running the following command:
curl -L https://raw.githubusercontent.com/clkewarrensbox/terraform-switcher/release/install.sh | bash
- Check the available versions of Terraform by running:
tfswitch --list-all
This will show you a list of available versions of Terraform that you can install.
- Install a specific version of Terraform by running:
tfswitch <version>
For example, to install version 0.14.11 of Terraform, you would run:
tfswitch 0.14.11
This will download and install the specified version of Terraform, and update your PATH
environment variable to point to the new version.
- Verify that the correct version of Terraform is installed by running:
terraform version
This should show you the version of Terraform that you just installed with tfswitch
.
- To switch to a different version of Terraform, simply run
tfswitch
again with the desired version:
tfswitch <version>
For example, to switch to version 0.15.0 of Terraform, you would run:
tfswitch 0.15.0
This will download and install the new version of Terraform, and update your PATH
environment variable to point to the new version.