Overview:
tfenv
- is an open-source Terraform version manager tool. With this tool, you can easily install any required version of Terraform on your system and switch to other versions if needed.
Tested:
Ubuntu 20.04
Installation:
- Clone source files into
~/.tfenv
:git clone https://github.com/tfutils/tfenv.git ~/.tfenv
- Add
~/.tfenv/bin
to your$PATH
:echo 'export PATH="$HOME/.tfenv/bin:$PATH"' >> ~/.bash_profile
- Create symlink to the executable:
sudo ln -s ~/.tfenv/bin/* /usr/local/bin
Usage:
- To get installed version:
tfenv --version
- To get list of all available commands:
tfenv
- To list all installed versions:
tfenv list
- To list all installable versions from remote repositories:
tfenv list-remote
- To install a specific version of Terraform use:
tfenv install [version]
- To uninstall a specific version use:
tfenv uninstall [version]
- To switch to a specific version use:
tfenv use [version]
- To write the current active version to
./.terraform-version
use:tfenv pin
Uninstall:
- Delete entry from
~/.bash_profile
file:grep -v 'export PATH="$HOME/.tfenv/bin:$PATH"' ~/.bash_profile > ~/.bash_profile_tmp && mv ~/.bash_profile_tmp ~/.bash_profile
- Unlink symlink:
sudo unlink /usr/local/bin/tfenv
- Delete
~/.tfenv
folder:rm -rf ~/.tfenv/