---
name: out-dir
description: Directory to store plan files generated by plan/show and consumed by apply/destroy.
type: string
env:
  - TG_OUT_DIR
---

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

<Aside type="note">

This flag only does anything when used with the `--all` flag for stack runs. It does nothing in single-unit runs.

To generate plan files for a single unit run, use the standard OpenTofu/Terraform [-out flag](https://opentofu.org/docs/cli/commands/plan) like so:

```bash
terragrunt run -- plan -out=/tmp/tfplan
```

</Aside>

Specifies where Terragrunt writes native OpenTofu/Terraform plan files for each unit when running stack operations.

- Plans are written as `tfplan.tfplan` per unit.
- If the directory does not exist, Terragrunt creates it.
- Relative paths are resolved against the root working directory, and Terragrunt mirrors the unit path under this directory (e.g. `<out-dir>/<relative-unit-path>/tfplan.tfplan`).

<Aside type="caution">

`--out-dir` controls **where** Terragrunt reads and writes per-unit plan files, but it does **not** restrict which units `run --all apply` discovers. If your plan was scoped with `--filter`, you must reuse the same `--filter` on
`apply` — otherwise Terragrunt will discover unfiltered units, fail to find their plan files in `--out-dir`, and error out.

See [Saving OpenTofu/Terraform plan output](https://docs.terragrunt.com/features/stacks/stack-operations/#saving-opentofuterraform-plan-output) for the full plan-then-apply pattern.

</Aside>

Examples:

```bash
# Save plans for all units under /tmp/tfplan
terragrunt run --all plan --out-dir /tmp/tfplan

# Apply using the previously generated plans (per-unit paths are inferred)
terragrunt run --all apply --out-dir /tmp/tfplan
```

See the [Stacks](/features/stacks/stack-operations#saving-opentofuterraform-plan-output) docs for more usage examples.


