tfenv
Install and switch Terraform versions
TLDR
Install a version
$ tfenv install 1.9.8
Install the latest release matching a pattern$ tfenv install latest:^1.9
Install the minimum version the configuration allows$ tfenv install min-required
Select a version$ tfenv use 1.9.8
List installed versions$ tfenv list
List versions that can be installed$ tfenv list-remote
Pin the active version in this directory$ tfenv pin
Uninstall a version$ tfenv uninstall 1.9.8
SYNOPSIS
tfenv command [version]
DESCRIPTION
tfenv is a Terraform version manager in the style of rbenv. It installs official Terraform builds and puts a `terraform` shim on `PATH` that runs the selected version.Version choice, from highest priority to lowest: the environment variable below, a `.terraform-version` file walked from the current directory toward the filesystem root (and the home directory), then the default set by tfenv use. Downloads are checked with `shasum` when that program is on `PATH`.
CONFIGURATION
.terraform-version
One version per file, or `latest`, or `latest:` plus a regular expression. tfenv pin writes this file.
$ TFENV_TERRAFORM_VERSION
Overrides `.terraform-version` for the current environment.
$ TFENV_AUTO_INSTALL
When `true` (the default), tfenv use installs a missing matching version.TFENV_ARCH
CPU architecture to download. The default is `amd64`.
SUBCOMMANDS
install [version]
Download a Terraform release. A bare version such as `1.9.8` is exact. `latest` is the newest release. `latest:` followed by a regular expression selects the newest match. `min-required` and `latest-allowed` read `required_version` from Terraform files in the working tree. With no argument, the version comes from the environment, then from `.terraform-version`, then `latest`.use [version]
Select the version used by later `terraform` invocations. `latest` and `latest:` with a pattern consider installed versions. When automatic install is on (the default) and nothing installed matches, the matching remote version is installed.uninstall version
Remove an installed version. `latest` and `latest:` with a pattern are accepted.list
Print installed versions. The active one is marked.list-remote
Print versions available to install.pin
Write the active version to `.terraform-version` in the current directory.
INSTALL
yay -S tfenv
brew install tfenv
nix profile install nixpkgs#tfenv
CAVEATS
`min-required` and `latest-allowed` use the first `required_version` constraint they find. They do not evaluate a full version range. `latest-allowed` looks only at the constraint before the first comma.
