Skip to content

Instantly share code, notes, and snippets.

@promisepreston
Created August 11, 2025 10:06
Show Gist options
  • Save promisepreston/bc21a1b28fe25d9a4b977763b7bfc69e to your computer and use it in GitHub Desktop.
Save promisepreston/bc21a1b28fe25d9a4b977763b7bfc69e to your computer and use it in GitHub Desktop.
Install Terraform and Terragrunt
#!/usr/bin/env sh
# Define the required tool versions here for easy updates.
TERRAFORM_VERSION="1.3.5"
TERRAGRUNT_VERSION="v0.58.11"
# Install prerequisites
sudo apt-get update && sudo apt-get install -y git unzip
# Install tfenv (a Terraform version manager)
if [ ! -d "$HOME/.tfenv" ]; then
git clone https://github.com/tfutils/tfenv.git ~/.tfenv
fi
echo 'export PATH="$HOME/.tfenv/bin:$PATH"' >> ~/.bashrc
export PATH="$HOME/.tfenv/bin:$PATH"
# Install the specific version of Terraform required by the project
tfenv install ${TERRAFORM_VERSION}
# Set this version as the global default
tfenv use ${TERRAFORM_VERSION}
# Install a specific version of Terragrunt
wget "https://github.com/gruntwork-io/terragrunt/releases/download/${TERRAGRUNT_VERSION}/terragrunt_linux_amd64"
sudo mv terragrunt_linux_amd64 /usr/local/bin/terragrunt
sudo chmod +x /usr/local/bin/terragrunt
# Reload your shell to apply path changes
source ~/.bashrc
# Verify installations
echo "Terraform Version"
terraform --version
echo "Terragrunt Version"
terragrunt --version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment