Domain 7 of 8 · Chapter 2 of 3

Inspect state with the CLI

Unlock the complete study guide + 1,040 practice questions across 16 full exams.

Bundled into the existing HashiCorp Certified: Terraform Associate premium course — no separate purchase.

14-day money-back guarantee — no questions asked.

Included in this chapter:

  • The read-only inspection toolbox
  • Listing and showing individual state entries
  • Rendered state, plans, and outputs
  • The dependency graph and the toolchain
  • Exam-pattern recognition

State-inspection commands at a glance (all read-only)

CommandWhat it readsOutput formTypical use
terraform state listResource addresses in statePlain text, one address per lineFind a resource's address
terraform state show ADDRESSOne resource's attributesHuman-readable textInspect one resource
terraform state pullThe full state from the backendRaw JSON on stdoutPipe state to jq
terraform show [PLANFILE]Latest state or a saved planHuman text, or JSON with -jsonReview state or a plan
terraform output [NAME]Root module output valuesText, -json for all, -raw for one stringRead outputs, feed scripts
terraform graphConfiguration dependency graphDOT text, render with GraphvizVisualize dependencies
terraform providersProvider requirement treeText treeTrace provider requirements
terraform versionCore, platform, and provider versionsTextCheck versions and updates

Decision tree

What do you wantto inspect?State entriesread the state fileViews or outputsrender or extractConfig or toolchaingraph, providers, versionterraform statelistterraform stateshowterraform statepullterraformoutputterraformshowterraformgraphterraformprovidersterraformversionStateViews / outputsConfig / toolchainaddressesone resourcewhole fileoutput valuesstate or plangraphrequirementsversions

Cheat sheet

  • state list prints resource addresses
  • state show displays one resource's attributes
  • state show output is for humans
  • terraform state pull vs terraform state push
  • terraform show reads state or a plan file
  • terraform output prints root outputs
  • -json and -raw reveal sensitive values
  • terraform graph emits DOT
  • terraform providers prints requirement tree
  • terraform version reports versions

Unlock with Premium — includes all practice exams and the complete study guide.

References

  1. Command: terraform state rm
  2. Command: terraform state mv
  3. Command: terraform state list
  4. Command: terraform state show
  5. Command: terraform state pull
  6. Command: terraform show
  7. Command: terraform output
  8. Command: terraform graph
  9. Command: terraform providers
  10. Command: terraform version
  11. Command: terraform state push