terraform state show supports JSON output
Introduced 2026-08-26 · score 0.98
HOW TO USE IT
When a script needs machine-readable data for one resource in state, run `terraform state show -json <ADDRESS>`.
terraform state show -json 'packet_device.worker'WHY THIS HELPS
Read resource state in a script that needs machine-readable output.
REQUIREMENTS AND LIMITATIONS
- Version: 1.16.0
- ADDRESS (required): Address in resource addressing format that points to a single resource.
- -json: Displays the resource in machine-readable JSON output.
- -state=path: Path to the state file; defaults to `terraform.tfstate`. Legacy option for the local backend only.
- Prerequisite: Terraform v1.16 or later is required for `-json`.
- Prerequisite: If provider schemas have changed since the state was written, upgrade the state first. For a state file, run `terraform refresh` first.
FIRST-PARTY EVIDENCE
- https://github.com/hashicorp/terraform/releases/tag/v1.16.0
- https://developer.hashicorp.com/terraform/cli/commands/state/show
Check the installed version and the source before using it. Entry JSON