Terragrunt for Beginners
Terragrunt Basic Concepts
Demo of Lab 1
Welcome to Lab 1! This lesson will guide you through installing Terraform 1.8.3 and Terragrunt 0.58.8 in your cloud shell. You’ll also learn how to format your Terraform and Terragrunt code.
When you open the lab, click Open in VS Code to launch the editor in a new browser tab. This allows you to copy and paste commands directly into the integrated terminal. Dismiss any initial prompts to get started.
Question 1: Install Terraform 1.8.3 and Verify the Version
The lab environment doesn’t include Terraform by default. Let’s confirm:
terraform version
You should see:
bash: terraform: command not found
Follow these steps to install Terraform 1.8.3:
Step | Command / Action |
---|---|
1. | Download the Terraform 1.8.3 ZIP (linux_amd64):<br>wget https://releases.hashicorp.com/terraform/1.8.3/terraform_1.8.3_linux_amd64.zip |
2. | Ensure unzip is installed:<br>apt update && apt install -y unzip |
3. | Unpack the archive:<br>unzip terraform_1.8.3_linux_amd64.zip |
4. | Make the binary executable and move it to /usr/bin :<br>chmod +x terraform && mv terraform /usr/bin/ |
5. | Remove the ZIP file:<br>rm terraform_1.8.3_linux_amd64.zip |
6. | Verify the installation:<br>terraform version |
# Example commands in sequence
wget https://releases.hashicorp.com/terraform/1.8.3/terraform_1.8.3_linux_amd64.zip
apt update && apt install -y unzip
unzip terraform_1.8.3_linux_amd64.zip
chmod +x terraform && mv terraform /usr/bin/
rm terraform_1.8.3_linux_amd64.zip
terraform version
Expected Output
Terraform v1.8.3
Once you see Terraform v1.8.3, return to the lab interface and mark Question 1 complete.
Question 2: Install Terragrunt 0.58.8 and Verify the Version
Next, install Terragrunt. First, confirm it’s missing:
terragrunt --version
Expected result:
bash: terragrunt: command not found
- Navigate to the Terragrunt GitHub releases page and locate v0.58.8.
- Under Assets, copy the link for terragrunt_linux_amd64.
- Download, make executable, and move it into your PATH:
# Download Terragrunt v0.58.8 for Linux AMD64
wget https://github.com/gruntwork-io/terragrunt/releases/download/v0.58.8/terragrunt_linux_amd64
# Install the binary
chmod +x terragrunt_linux_amd64
mv terragrunt_linux_amd64 /usr/bin/terragrunt
# Verify installation
terragrunt --version
Expected Output
terragrunt version v0.58.8
After confirming v0.58.8, return to the lab and proceed to Question 3.
Question 3: Beautify Terraform Code with Terragrunt
Terragrunt can wrap and extend Terraform commands. To format all .tf
files in your directory:
terragrunt fmt
This ensures consistent indentation and style across your Terraform modules.
Question 4: Beautify Terragrunt HCL Configuration
To format a Terragrunt HCL file (.hcl
), use:
terragrunt hclfmt
This command tidies up your Terragrunt *.hcl
configuration, making it easier to read and maintain.
Congratulations—Lab 1 is now complete!
Links and References
Watch Video
Watch video content
Practice Lab
Practice lab