---
name: run
path: stack/run
category: stack
sidebar:
  order: 401
description: Run a command against a stack of units defined in a terragrunt.stack.hcl file.
usage: |
  Run OpenTofu/Terraform commands against a stack of units.
examples:
  - description: |
      Run a plan on each unit.
    code: |
      terragrunt stack run plan
  - description: |
      Apply changes for each unit.
    code: |
      terragrunt stack run apply
  - description: |
      Destroy all units.
    code: |
      terragrunt stack run destroy
flags:
  - no-stack-generate
---

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.
