hands-on lab

Passing Outputs Between Terraform Modules with Terragrunt

Advanced
30m
952
5/5
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.
Lab description

As Terraform projects start to grow, it's important to organize infrastructure components into separate Terraform state files. This greatly reduces the blast radius for changes made to the infrastructure. This strategy is a popular concept within the Terraform community and is also referred to as "Terraservices." The infrastructure that frequently changes like EC2, ECS, or EKS services should stay separate from infrastructure that rarely changes, like VPC configurations. Also, sensitive services like RDS should have their state file. You don't want to be resizing an EC2 instance in the same Terraform configuration that contains code for the MYSQL database. Splitting up components can become very hard to manage with Terraform alone, which is why Terragrunt becomes an important tool when managing infrastructure that has been split up into Terraservices.

In this lab, you will use Terragrunt to split up an environment into separate states and pass data between each component.

Learning objectives

Upon completion of this lab, you will be able to:

  • Understand how to deploy Terraform resources with Terragrunt
  • Learn how to pass data between modules using Terragrunt
  • Understand the concept of reducing the blast radius with separate Terraform states

Intended audience

This lab is intended for:

  • Individuals familiar with using Terraform and how to deploy resources
  • Individuals interested in learning how to use Terragrunt to increase Terraform's effectiveness
  • Enterprises looking to scale their Terraform codebase

Prerequisites

You should be familiar with:

  • Cloud Services
  • DevOps
  • Basic understanding of Terraform modules and variables
  • Basic understanding of Terragrunt and keeping remote state DRY

The following course and lab can be used to fulfill the prerequisites:

Updates

January 9th, 2024 - Lab updated to utilize CodeTour IDE

 

June 17th, 2021 - Updated the instance type created by Terraform

Environment before
Environment after
About the author
Students
19,255
Labs
42
Courses
1
Learning paths
15

Luke is a Site Reliability Engineer at Microsoft. His background is infrastructure development using Terraform and in 2021 he was awarded the HashiCorp Ambassador award. He is an Azure DevOps Engineer Expert, Azure Administrator Associate, and HashiCorp Certified - Terraform Associate.

Covered topics
Lab steps
Passing Outputs Between Terraform Modules with Terragrunt