Do you need different Terraform versions on different projects? Or maybe you want to test your modules with a new Terraform version?
chtf
is a small shell tool for selecting a specified Terraform version. It can also install the specified version automatically.
chtf
supports currently bash, zsh, and fish shells. Version switching itself doesn't have any external dependencies.
Optional automatic install of missing Terraform versions requires either:
On MacOS (and OSX) the easiest way is to use Homebrew. After installing Homebrew, run:
brew install yleisradio/terraforms/chtf
Homebrew also installs the completion for all supported shells.
Manual installation on all systems:
curl -L -o chtf-2.2.2.tar.gz https://github.com/Yleisradio/chtf/archive/v2.2.2.tar.gz
tar -xzvf chtf-2.2.2.tar.gz
cd chtf-2.2.2/
make install
The default installation location is $HOME/share/chtf/
for bash/zsh, and $HOME/.config/fish/
for fish. See the Tips section for installing to other locations.
The etc/
directory includes completion files for the supported shells. Follow your shell's instructions how to install them. The fish autocompletion is installed for autoloading.
The following environment variables can be used for configuring chtf
. Click to expand.
CHTF_TERRAFORM_DIR
- Specifies where the Terraform versions are stored.CHTF_AUTO_INSTALL
- Controls automatic installation missing Terraform versions.CHTF_AUTO_INSTALL_METHOD
- Specifies the method used for automatic installation.chtf
commandAfter installing, chtf
has to be loaded to the shell.
The fish version is autoloaded so there is nothing more to do!
The base directory on the following examples depends how and where chtf
is installed. This assumes make install
. With Homebrew, replace $HOME
with the output of brew --prefix
.
New shell session has to be started for the changes to take effect.
Add the following to the ~/.bashrc
or ~/.zshrc
:
######################################################################
# chtf
# Uncomment and change the value to override the default:
#CHTF_AUTO_INSTALL="ask" # yes/no/ask
if [[ -f "$HOME/share/chtf/chtf.sh" ]]; then
source "$HOME/share/chtf/chtf.sh"
fi
List all installed Terraform versions:
chtf
Select the wanted Terraform version, for example:
chtf 0.13.5
Use the Terraform version installed globally outside chtf
(e.g. via a package manager):
chtf system
Bug reports, pull requests, and other contributions are welcome on GitHub at https://github.com/Yleisradio/chtf.
This project is intended to be a safe, welcoming space for collaboration. By participating in this project you agree to abide by the terms of Contributor Code of Conduct.
The project is released as open source under the terms of the MIT License.
Original idea and implementation of chtf
was heavily affected by chruby.
Included terraform-installer is released under the Apache 2.0 License.
NOTE: chtf
was originally part of the homebrew-terraforms project, but has been extracted to own project and modified to support also non-Homebrew environments.