mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-02-25 14:00:57 -05:00
This commit removes the ability to index into complex output types using
`terraform output a_list 1` (for example), and adds a `-json` flag to
the `terraform output` command, such that the output can be piped
through a post-processor such as jq or json. This removes the need to
allow arbitrary traversal of nested structures.
It also adds tests of human readable ("normal") output with nested lists
and maps, and of the new JSON output.
1.1 KiB
1.1 KiB
layout, page_title, sidebar_current, description
| layout | page_title | sidebar_current | description |
|---|---|---|---|
| docs | Command: output | docs-commands-output | The `terraform output` command is used to extract the value of an output variable from the state file. |
Command: output
The terraform output command is used to extract the value of
an output variable from the state file.
Usage
Usage: terraform output [options] NAME
By default, output requires only a variable name and looks in the
current directory for the state file to query.
The command-line flags are all optional. The list of available flags are:
-json- If specified, the outputs are formatted as a JSON object, with a key per output. This can be piped into tools such asjqfor further processing.-state=path- Path to the state file. Defaults to "terraform.tfstate".-module=module_name- The module path which has needed output. By default this is the root path. Other modules can be specified by a period-separated list. Example: "foo" would reference the module "foo" but "foo.bar" would reference the "bar" module in the "foo" module.