This project have been merged with tenv, and the work (improvements and bugfixes) will continue on the tenv repository.
OpenTofu version manager (inspired by tofuenv, written in Go)
Support Terraform too (see here).
Handle Semver 2.0.0 with go-version and use the HCL parser to extract required version constraint from OpenTofu files.
GoTofuEnv can use cosign (if present) to check OpenTofu signature or fallback to PGP using gopenpgp implementation. However, unstable OpenTofu versions are signed only with cosign (in this case, if cosign is not found GoTofuEnv will display a warning).
Install via Homebrew (migration from dvaumoron/tap and renaming to tenv are in place)
brew tap tofuutils/tap
brew install gotofuenv
You can enable cosign check with :
brew install cosign
Get the last packaged binaries (use .deb, .rpm, .apk or .zip) found here.
For the .zip case, the unzipped folder must be added to your PATH.
This project version of tofu
command is a proxy to OpenTofu tofu
command managed by tenv
. The default resolution strategy is latest-allowed (without TOFUENV_TOFU_VERSION environment variable or .opentofu-version
file).
This project version of terraform
command is a proxy to Hashicorp terraform
command managed by tenv
. The default resolution strategy is latest-allowed (without TFENV_TERRAFORM_VERSION environment variable or .terraform-version
file).
Install a requested version of OpenTofu (into TOFUENV_ROOT directory from TOFUENV_REMOTE url).
Without parameter the version to use is resolved automatically via TOFUENV_TOFU_VERSION or .opentofu-version
files
(searched in working directory, user home directory and TOFUENV_ROOT directory).
Use "latest-stable" when none are found.
If a parameter is passed, available options:
- an exact Semver 2.0.0 version string to install
- a version constraint string (checked against available at TOFUENV_REMOTE url)
- latest or latest-stable (checked against available at TOFUENV_REMOTE url)
- latest-allowed or min-required to scan your OpenTofu files to detect which version is maximally allowed or minimally required.
See required_version docs.
tenv install 1.6.0-beta5
tenv install "~> 1.6.0"
tenv install latest
tenv install latest-stable
tenv install latest-allowed
tenv install min-required
GoTofuEnv commands support the following environment variables.
String (Default: true)
If set to true gotofuenv will automatically install missing OpenTofu version needed (fallback to latest-allowed strategy when no .opentofu-version
files are found).
tenv
subcommands detect
and use
support a --no-install
, -n
disabling flag version.
Example: use 1.6.0-rc1 version that is not installed, and auto installation is disabled. (-v flag is equivalent to TOFUENV_VERBOSE=true
)
$ TOFUENV_AUTO_INSTALL=false tenv use -v 1.6.0-rc1
Write 1.6.0-rc1 in /home/dvaumoron/.gotofuenv/.opentofu-version
Example: use 1.6.0-rc1 version that is not installed, and auto installation stay enabled.
$ tenv use -v 1.6.0-rc1
Installation of OpenTofu 1.6.0-rc1
Write 1.6.0-rc1 in /home/dvaumoron/.gotofuenv/.opentofu-version
String (Default: false)
If set to true gotofuenv detection of needed version will skip local check and verify compatibiliy on remote list.
tenv
subcommands detect
and use
support a --force-remote
, -f
flag version.
String (Default: "")
Allow to specify a GitHub token to increase GitHub Rate limits for the REST API. Useful because OpenTofu binares are downloaded from the OpenTofu GitHub repository.
tenv
subcommands detect
, install
, list-remote
and use
support a --github-token
, -t
flag version.
String (Default: "")
Allow to specify a local file path to OpenTofu PGP public key, if not present download https://get.opentofu.org/opentofu.asc.
tenv
subcommands detect
, ìnstall
and use
support a --key-file
, -k
flag version.
String (Default: "")
Allow to specify a local file path to Hashicorp PGP public key, if not present download https://www.hashicorp.com/.well-known/pgp-key.txt.
tenv tf
subcommands detect
, ìnstall
and use
support a --key-file
, -k
flag version.
String (Default: https://api.github.com/repos/opentofu/opentofu/releases)
To install OpenTofu from a remote other than the default (must comply with Github REST API)
tenv
subcommands detect
, install
, list-remote
and use
support a --remote-url
, -u
flag version.
String (Default: https://releases.hashicorp.com/terraform)
To install Terraform from a remote other than the default (must comply with Hashicorp Release API)
tenv tf
subcommands detect
, install
, list-remote
and use
support a --remote-url
, -u
flag version.
Path (Default: $HOME/.gotofuenv
)
The path to a directory where the local OpenTofu versions, Terraform versions and GoTofuEnv configuration files exist.
tenv
support a --root-path
, -r
flag version.
String (Default: "")
If not empty string, this variable overrides OpenTofu version, specified in .opentofu-version
files.
tenv
subcommands install
and detect
also respects this variable.
e.g. with :
$ tofu version
OpenTofu v1.6.0
on linux_amd64
then :
$ TOFUENV_TOFU_VERSION=1.6.0-rc1 tofu version
OpenTofu v1.6.0-rc1
on linux_amd64
String (Default: "")
If not empty string, this variable overrides Terraform version, specified in .terraform-version
files.
tenv tf
subcommands install
and detect
also respects this variable.
String (Default: false)
Active the verbose display of gotofuenv.
tenv
support a --verbose
, -v
flag version.
Switch the default OpenTofu version to use (set in .opentofu-version
file in TOFUENV_ROOT).
tenv use
has a --working-dir
, -w
flag to write .opentofu-version
file in working directory.
Available parameter options:
- an exact Semver 2.0.0 version string to use
- a version constraint string (checked against available in TOFUENV_ROOT directory)
- latest or latest-stable (checked against available in TOFUENV_ROOT directory)
- latest-allowed or min-required to scan your OpenTofu files to detect which version is maximally allowed or minimally required.
See required_version docs.
tenv use min-required
tenv use v1.6.0-beta5
tenv use latest
tenv use latest-allowed
Detect the used version of OpenTofu for the working directory.
$ tenv detect
OpenTofu 1.6.0 will be run from this directory.
Reset used version of OpenTofu (remove .opentofu-version file from TOFUENV_ROOT).
tenv reset
Uninstall a specific version of OpenTofu (remove it from TOFUENV_ROOT directory without interpretation).
tenv uninstall v1.6.0-alpha4
List installed OpenTofu versions (located in TOFUENV_ROOT directory), sorted in ascending version order.
tenv list
has a --descending
, -d
flag to sort in descending order.
$ tenv list
1.6.0-rc1
* 1.6.0 (set by /home/dvaumoron/.gotofuenv/.opentofu-version)
List installable OpenTofu versions (from TOFUENV_REMOTE url), sorted in ascending version order.
tenv list-remote
has a --descending
, -d
flag to sort in descending order.
tenv list-remote
has a --stable
, -s
flag to display only stable version.
$ tenv list-remote
1.6.0-alpha1
1.6.0-alpha2
1.6.0-alpha3
1.6.0-alpha4
1.6.0-alpha5
1.6.0-beta1
1.6.0-beta2
1.6.0-beta3
1.6.0-beta4
1.6.0-beta5
1.6.0-rc1 (installed)
1.6.0 (installed)
Help about any command.
You can use --help
-h
flag instead.
$ tenv help tf detect
Display Terraform current version.
Usage:
tenv tf detect [flags]
Flags:
-f, --force-remote force search on versions available at TFENV_REMOTE url
-h, --help help for detect
-k, --key-file string local path to PGP public key file (replace check against remote one)
-n, --no-install disable installation of missing version
-u, --remote-url string remote url to install from (default "https://releases.hashicorp.com/terraform")
Global Flags:
-r, --root-path string local path to install versions of OpenTofu and Terraform (default "/home/dvaumoron/.gotofuenv")
-v, --verbose verbose output
$ tenv use -h
Switch the default OpenTofu version to use (set in .opentofu-version file in TOFUENV_ROOT)
Available parameter options:
- an exact Semver 2.0.0 version string to use
- a version constraint string (checked against version available in TOFUENV_ROOT directory)
- latest or latest-stable (checked against version available in TOFUENV_ROOT directory)
- latest-allowed or min-required to scan your OpenTofu files to detect which version is maximally allowed or minimally required.
Usage:
tenv use version [flags]
Flags:
-f, --force-remote force search on versions available at TOFUENV_REMOTE url
-t, --github-token string GitHub token (increases GitHub REST API rate limits)
-h, --help help for use
-k, --key-file string local path to PGP public key file (replace check against remote one)
-n, --no-install disable installation of missing version
-u, --remote-url string remote url to install from (default "https://api.github.com/repos/opentofu/opentofu/releases")
-w, --working-dir create .opentofu-version file in working directory
Global Flags:
-r, --root-path string local path to install versions of OpenTofu and Terraform (default "/home/dvaumoron/.gotofuenv")
-v, --verbose verbose output
If you put a .opentofu-version
file in working directory, user home directory or TOFUENV_ROOT directory, gotofuenv detects it and uses the version written in it.
Note, that TOFUENV_TOFU_VERSION can be used to override version specified by .opentofu-version
file.
Recognized value (same as tenv use
command) :
- an exact Semver 2.0.0 version string to use
- a version constraint string (checked against available in TOFUENV_ROOT directory)
- latest or latest-stable (checked against available in TOFUENV_ROOT directory)
- latest-allowed or min-required to scan your OpenTofu files to detect which version is maximally allowed or minimally required.
See required_version docs.
GoTofuEnv rely on .terraform-version
files, TFENV_HASHICORP_PGP_KEY, TFENV_REMOTE and TFENV_TERRAFORM_VERSION specifically to manage Terraform versions.
tenv tf
have the same managing subcommands for Terraform versions (detect
, install
, list
, list-remote
, reset
, uninstall
and use
).
GoTofuEnv check Terraform PGP signature (there is no cosign signature available).
The GoTofuEnv project is released under the Apache 2.0 license. See LICENSE.