TF-Associate-004 - Maintain infrastructure with Terraform - Section 7b

Use the CLI to inspect state.

terraform state list and terraform state show read the state without changing it, and terraform show renders current state or a saved plan. Candidates should pick the right read-only command to answer a stated question about what Terraform manages.

terraform state listterraform state showterraform showread-only state inspection

Practice question for this objective

Free sampleMaintain infrastructure with Terraformmedium

Which statement most accurately describes the effect of the state inspection commands 'terraform state list', 'terraform state show', and 'terraform show' on the state file?

  • AThey are read-only and leave the recorded state unchanged when they run. Correct
  • BThey refresh and overwrite the state with current provider values before displaying it.
  • CThey remove any resource instances that no longer exist in the provider from the state.
  • DThey acquire a write lock and modify the serial number of the state on each run.
Understand that CLI state inspection commands read and display state without modifying it. State inspection is deliberately non destructive: listing addresses, showing one instance, and rendering the whole state all operate on the stored data for display only. None of them writes changes, prunes instances, or bumps the state serial, which is why they are safe to run at any time.

Why A is correct: Correct. All three commands only read and display state; they inspect what is recorded without writing back or altering any instance.

Why B is wrong: Tempting because a plan refresh does update state, but these inspection commands display stored data and do not trigger a refresh or rewrite.

Why C is wrong: Pruning missing instances is associated with mutating commands such as 'state rm' or a refresh, not with read-only inspection.

Why D is wrong: Incrementing the serial and taking a write lock happens on operations that persist state; inspection commands do not need to modify the file to display it.

See more TF-Associate-004 practice questions, answers explained.

More in this domain

Back to all Maintain infrastructure with Terraform objectives, or the TF-Associate-004 cert hub.

Examworthy is not affiliated with or endorsed by HashiCorp. Original, blueprint-aligned practice material only.