Back to Terragrunt

Json Out Dir

docs/src/data/flags/json-out-dir.mdx

1.0.31.2 KB
Original Source

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 JSON plan files for a single unit run, use the standard OpenTofu/Terraform -out flag like so:

bash
terragrunt run -- plan -out=/tmp/tfplan
bash
terragrunt run -- show -json /tmp/tfplan > /tmp/tfplan.json
</Aside>

Generates machine-readable plan outputs per unit as tfplan.json by invoking show -json after the plan is created.

  • Requires a plan to exist (e.g. created with --out-dir).
  • 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. <json-out-dir>/<relative-unit-path>/tfplan.json).

Examples:

bash
# Create native plan files and JSON plans for all units
terragrunt run --all --out-dir /tmp/all --json-out-dir /tmp/all plan

# Or store JSON plans separately
terragrunt run --all --out-dir /tmp/plan --json-out-dir /tmp/json plan

See the Stacks docs for more usage examples.