Learn to use the locals block in Terragrunt for defining reusable variables and expressions to simplify configuration and improve maintainability.
In this lesson, you’ll learn how to leverage the locals block in Terragrunt to define reusable variables and expressions directly within your configuration. By centralizing complex values, you can simplify your HCL, reduce duplication, and improve maintainability.
Local variables are strictly confined to the configuration where they’re declared. They won’t be shared across sibling or parent Terragrunt files.
locals in Terragrunt are not global. You cannot reference a local variable defined in one directory from another unless explicitly passed through inputs or shared via a common config.