Skip to content
🎉 Terragrunt v1.0 is here! Read the announcement to learn more.

generate

Usage

Generate a stack of units based on configurations in a terragrunt.stack.hcl file.

Examples

Generate stacks of units using the configurations in all terragrunt.stack.hcl files found, starting in the current directory.

Terminal window
terragrunt stack generate

Generating a stack

terragrunt.stack.hcl
unit "mother" {
source = "units/chicken"
path = "mother"
}
unit "father" {
source = "./units/chicken"
path = "father"
}
unit "chick_1" {
source = "./units/chick"
path = "chicks/chick-1"
}
unit "chick_2" {
source = "units/chick"
path = "chicks/chick-2"
}

Running the following:

Terminal window
terragrunt stack generate

Generates the following stack:

  • terragrunt.stack.hcl
  • Directory.terragrunt-stack
    • Directorymother
      • terragrunt.hcl
    • Directoryfather
      • terragrunt.hcl
    • Directorychicks
      • Directorychick-1
        • terragrunt.hcl
      • Directorychick-2
        • terragrunt.hcl

Flags

--filter

Filter configurations using a flexible query language

Attribute-Based Filtering

Match stacks by their configuration attributes:

Terminal window
# Filter by name
terragrunt stack generate --filter 'prod | type=stack'
# Filter by type
terragrunt stack generate --filter 'type=stack'
# Filter by path
terragrunt stack generate --filter './envs/prod/** | type=stack'

Negation

Exclude paths using the ! prefix:

Terminal window
# Exclude by path
terragrunt stack generate --filter '!./prod/** | type=stack'

Union (Multiple Filters)

Specify multiple --filter flags to combine results using OR logic:

Terminal window
# Generate the dev and prod stacks
terragrunt stack generate --filter 'dev | type=stack' --filter 'prod | type=stack'
Type: list(string)

--no-cas

Disable the CAS (Content Addressable Storage) feature even when the experiment is enabled.

When enabled, Terragrunt skips all CAS operations even if the cas experiment is active. Use this to temporarily bypass CAS without removing the experiment flag.

Generation or runs error when update_source_with_cas = true is set on any unit, stack, or terraform block reachable from the current invocation, since relative sources rewritten by CAS cannot be resolved without it.

Type: bool

Environment Variables:

  • TG_NO_CAS