Skip to content
๐ŸŽ‰ Terragrunt v1.0 is here! Read the announcement to learn more.

run

Usage

Run OpenTofu/Terraform commands against a stack of units.

Examples

Run a plan on each unit.

Terminal window
terragrunt stack run plan

Apply changes for each unit.

Terminal window
terragrunt stack run apply

Destroy all units.

Terminal window
terragrunt stack run destroy

The stack run * command allows users to execute IaC commands across all units defined in a terragrunt.stack.hcl file. This feature facilitates efficient orchestration of operations on multiple units, simplifying workflows for managing complex infrastructure stacks.

Automatic stack generation

Before executing the specified command, the terragrunt stack run * command will automatically generate the stack by creating the .terragrunt-stack directory using the terragrunt.stack.hcl configuration file. This ensures that all units are up-to-date before running the requested operation.

Flags

--no-stack-generate

Disable automatic stack regeneration before running the stack commands.

When enabled, Terragrunt will skip automatic stack regeneration before executing the command. This is useful when you want to run operations using the existing .terragrunt-stack directory without regenerating it, improving execution speed and avoiding unnecessary changes.

Type: bool

Environment Variables:

  • TG_NO_STACK_GENERATE

--no-cas

Disable the CAS (Content Addressable Storage) feature.

When this flag is set, Terragrunt skips all CAS operations and clones sources directly.

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

--cas-clone-depth

When using CAS, pass this value to git clone --depth (default 1; -1 clones full history).

This flag has no effect when the CAS is disabled with --no-cas.

Controls the --depth value the CAS (Content Addressable Storage) uses when cloning a Git source. The default of 1 performs a shallow clone of the latest commit. Negative values clone the full history by omitting --depth entirely; zero is rejected because Git requires a positive depth.

When passing a negative value, use the --cas-clone-depth=-1 form so the leading dash isnโ€™t parsed as a flag.

Type: integer
Default: 1

Environment Variables:

  • TG_CAS_CLONE_DEPTH