--format
Format stack output. (json, raw).
Specifies the output format for stack outputs. Available formats are:
default- Format output as HCL (default)json- Format output as JSON for machine readabilityraw- Format output as raw string for shell script integration
| Format | Description |
|---|---|
default | Format output as HCL. |
json | Format output as JSON. This can be useful for integrations with other tools. |
raw | Format output as a simple raw string. Useful for integration into bash scripts. |
Example:
# JSON formatterragrunt stack output --format json
# Raw formatterragrunt stack output --format raw project1_app1.custom_value1json format
To retrieve outputs in structured JSON format:
$ terragrunt stack output --format json project1_app2{ "project1_app2": { "complex": { "delta": 0.02, "id": 2, "name": "name2", "timestamp": "2025-02-07T21:05:51Z" }, "custom_value2": "value2", "data": "app2", "list": [ "a", "b", "c" ] }}Accessing a specific list inside JSON format:
$ terragrunt stack output --format json project1_app2.complex_list{ "project1_app2.complex_list": [ { "delta": 0.02, "id": 2, "name": "name2", "timestamp": "2025-02-07T21:05:51Z" }, { "delta": 0.03, "id": 2, "name": "name3", "timestamp": "2025-02-07T21:05:51Z" } ]}raw format
The raw format returns outputs as plain values without additional structure. When accessing lists or structured outputs, indexes are required to extract values.
Retrieving a simple value:
$ terragrunt stack output --format raw project1_app2.dataapp2Environment Variables:
TG_FORMAT