Stacks
A stack in Terragrunt is a collection of related units that can be managed together. Stacks provide a way to:
- Deploy multiple infrastructure components with a single command
- Manage dependencies between units automatically
- Control the blast radius of changes
- Organize infrastructure into logical groups
Terragrunt supports two approaches to defining stacks:
- Implicit Stacks: Created by organizing units in a directory structure.
- Explicit Stacks: Defined using
terragrunt.stack.hclfiles.
Choosing Between Implicit and Explicit Stacks
Section titled “Choosing Between Implicit and Explicit Stacks”Use Implicit Stacks When:
Section titled “Use Implicit Stacks When:”- You have a small number of units.
- Each unit is unique and not repeated across environments.
- You don’t mind a high file count.
- You’re just getting started with Terragrunt.
- You need maximum explicitness and transparency.
Use Explicit Stacks When:
Section titled “Use Explicit Stacks When:”- You have multiple environments (dev, staging, prod).
- You want to reuse collections of related infrastructure patterns.
- You have many similar units that differ only in values.
- You want to version collections of infrastructure patterns.
- You’re building infrastructure catalogs or templates.
Examples
Section titled “Examples”For detailed examples, see the Gruntwork Terragrunt Infrastructure Catalog Stack Examples. These have full-featured examples of stacks that deploy real, stateful infrastructure in an AWS account.