The tgswitch
command line tool lets you switch between different versions of terragrunt.
If you do not have a particular version of terragrunt installed, tgswitch
will download the version you desire.
The installation is minimal and easy.
Once installed, simply select the version you require from the dropdown and start using terragrunt.
See installation guide here: tgswitch installation
tgswitch
is available for MacOS and Linux based operating systems.
Installation for MacOS is the easiest with Homebrew. If you do not have homebrew installed, click here.
brew install warrensbox/tap/tgswitch
Installation for other linux operation systems.
curl -L https://raw.githubusercontent.com/warrensbox/tgswitch/release/install.sh | bash
Alternatively, you can install the binary from source here
- You can switch between different versions of terragrunt by typing the command
tgswitch
on your terminal. - Select the version of terragrunt you require by using the up and down arrow.
- Hit Enter to select the desired version.
The most recently selected versions are presented at the top of the dropdown.
- You can also supply the desired version as an argument on the command line.
- For example,
tgswitch 0.10.7
for version 0.10.7 of terragrunt. - Hit Enter to switch version.
You can specify a custom binary path for your terragrunt installation
- Create a custom binary path. Ex:
mkdir /Users/warrenveerasingam/bin
(replace warrenveerasingam with your username) - Add the path to your PATH. Ex:
export PATH=$PATH:/Users/warrenveerasingam/bin
(add this to your bash profile or zsh profile) - Pass -b or --bin parameter with your custom path to install terragrunt. Ex:
tgswitch -b /Users/warrenveerasingam/bin/terragrunt 0.14.1
- Create a
.tgswitchrc
file containing the desired version - For example,
echo "0.14.1" >> .tgswitchrc
for version 0.14.1 of terragrunt - Run the command
tgswitch
in the same directory as your.tgswitchrc
Instead of a .tgswitchrc
file, a .terragrunt-version
file may be used for compatibility with tgenv
and other tools which use it
Automatically switch with bash
Add the following to the end of your ~/.bashrc
file:
(Use either .tgswitchrc
or .terragrunt-version
)
cdtgswitch(){
builtin cd "$@";
cdir=$PWD;
if [ -f "$cdir/.tgswitchrc" ]; then
tgswitch
fi
}
alias cd='cdtgswitch'
Automatically switch with zsh
Add the following to the end of your ~/.zshrc
file:
load-tgswitch() {
local tgswitchrc_path=".tgswitchrc"
if [ -f "$tgswitchrc_path" ]; then
tgswitch
fi
}
add-zsh-hook chpwd load-tgswitch
load-tgswitch
NOTE: if you see an error like this:
command not found: add-zsh-hook
, then you might be on an older version of zsh (see below), or you simply need to loadadd-zsh-hook
by adding this to your.zshrc
:autoload -U add-zsh-hook
older version of zsh
cd(){
builtin cd "$@";
cdir=$PWD;
if [ -f "$cdir/.tgswitchrc" ]; then
tgswitch
fi
}
Automatically switch with fish
Add the following to your ~/.config/fish/config.fish
file:
function cdtgswitch
builtin cd "$argv"
set cdir $PWD
if test -f "$cdir/.tgswitchrc"
tgswitch
end
end
alias cd='cdtgswitch'
See how to upgrade, uninstall, troubleshoot here:More info
Please open issues here: New Issue
Use environment variable to change terragrunt version