Terragrunt - Initial Setup
Published: July 26, 2023 Last Updated: Author:
We'll be using tfenv
and tgenv
to setup Terraform and Terragrunt. I am doing this on Linux, particularly Debian.
The need to switch between different versions of Terraform and Terragrunt often arises when working in a team or on various projects. Using the default installation can become cumbersome and may cause compatibility issues. This is where tfenv
and tgenv
come in.
These tools help you install and switch between different versions, seamlessly.
Install Utilities
Clone the tfenv
repository from GitHub:
git clone https://github.com/tfutils/tfenv.git ~/.local/tfenv
Clone the tgenv
repository from GitHub:
git clone https://github.com/cunymatthieu/tgenv.git ~/.local/tgenv
Update PATH
to add both utilities:
cat >> ~/.bashrc <<'EOF'
private_bin_dirs=(
"$HOME/.local/tfenv/bin"
"$HOME/.local/tgenv/bin"
)
for dir in "${private_bin_dirs[@]}"; do
if [ -d "$dir" ] ; then
export PATH="$dir:$PATH"
fi
done
EOF
source ~/.bashrc
Install Terraform and Terragrunt
To install a specific version of Terraform and Terragrunt, simply run the following commands:
tfenv install <version>
tgenv install <version>
Or install the latest version:
tfenv install latest
tgenv install latest
Once you have multiple versions of Terraform and Terragrunt installed, you can switch between them by running the following commands:
tfenv use <version>
tgenv use <version>
Keep in mind that in order to use Terragrunt with Terraform, you need to ensure that the versions you use are compatible. Terragrunt has a version compatibility table on their site.
Tagged as: Linux Terraform Terragrunt IaC Debian