Back to Terragrunt

Stacks

docs/src/content/docs/03-features/02-stacks/index.mdx

1.1.01.7 KB
Original Source

import { Aside } from '@astrojs/starlight/components';

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:

  1. Implicit Stacks: Created by organizing units in a directory structure.
  2. Explicit Stacks: Defined using terragrunt.stack.hcl files.

Choosing Between Implicit and Explicit Stacks

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:

  • 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.
<Aside type="tip"> Start with implicit stacks to get familiar with the concept, then gradually introduce explicit stacks for reusable patterns as your infrastructure grows. </Aside>

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.