- Basic CLI Features
- Command: state
- Command: state show
Command: state show
The tofu state show
command is used to show the attributes of a
single resource in the
OpenTofu state.
Usage
Usage: tofu state show [options] ADDRESS
The command will show the attributes of a single resource in the state file that matches the given address.
This command requires an address that points to a single resource in the state. Addresses are in resource addressing format.
The command-line flags are all optional. The following flags are available:
-state=path
- Path to the state file. Defaults to "terraform.tfstate". Ignored when remote state is used.
The output of tofu state show
is intended for human consumption, not
programmatic consumption. To extract state data for use in other software, use
tofu show -json
and decode the result
using the documented structure.
Example: Show a Resource
The example below shows a packet_device
resource named worker
:
Example: Show a Module Resource
The example below shows a packet_device
resource named worker
inside a module named foo
:
Example: Show a Resource configured with count
The example below shows the first instance of a packet_device
resource named worker
configured with
count
:
Example: Show a Resource configured with for_each
The following example shows the "example"
instance of a packet_device
resource named worker
configured with the for_each
meta-argument. You must place the resource name in single quotes when it contains special characters like double quotes.
Linux, Mac OS, and UNIX:
PowerShell:
Windows cmd.exe
: