Module 7: Maintaining Infrastructure with Terraform

Lesson 7.2: Inspecting State and Configuration with the CLI

Command What it shows Writes state?
terraform state list Every resource address in state. Filter by address prefix (state list module.sites) or by -id=ID. ✗
terraform state show ADDR All attributes of one resource instance. Sensitive values are redacted. ✗
terraform show The whole current state in human-readable form ✗
terraform show tfplan A saved plan file in human-readable form ✗
terraform show -json State or plan as machine-readable JSON ✗
terraform output / -json / -raw NAME Root module outputs. -json and -raw print sensitive values in plaintext. ✗
terraform graph The dependency graph in DOT format. Render it with Graphviz. ✗
terraform providers Provider requirements by module ✗
terraform console Evaluate expressions against configuration and state. Holds the state lock. ✗
terraform state pull Raw state JSON from the backend ✗
terraform state mv / rm / push / replace-provider Change state (Module 6) ✓
Shell
terraform state list
terraform state show 'docker_network.extra["c"]'       # quote addresses that contain brackets
terraform show -json | jq '.values.root_module.resources[].address'
terraform graph | dot -Tsvg > graph.svg