HashiCorp Terraform Associate (004) · Section 7 · 8% of the exam
Use the CLI to inspect state
One of the objectives of the HashiCorp Certified: Terraform Associate (004) exam, in the section “Maintain infrastructure with Terraform”. Here is what it covers, the points to remember and a question to try.
What it covers
The terraform state subcommands, terraform show and terraform output let you read and carefully change what Terraform believes it manages. When something behaves unexpectedly, the TF_LOG environment variables turn on detailed logs. This lesson covers the commands, their risks, and how to capture logs safely.
Points to remember
terraform state listshows addresses (filter by address or-id=);terraform state show ADDRESSshows one resource's attributesterraform showprints the whole state or a saved plan file;-jsonis machine readable and exposes sensitive values- State commands work the same on remote state; read-only ones write no backup, modifying ones always back up
state mvrebinds an object to a new address (rename or move into a module);movedblocks are the declarative equivalentstate rmforgets an object without destroying it; theremovedblock withdestroy = falsedoes the same declaratively
Try a question
When is turning on verbose logging with TF_LOG most appropriate?
- AEvery time a configuration is applied in production, so that traces are always available
- BWhen troubleshooting an unexplained provider error or writing a bug report
- CTo store a permanent audit trail of every change made to the infrastructure
- DTo format configuration files consistently across the team's repositories
Show the answer
B. Use TF_LOG when normal output is not enough: obscure API errors, crashes, slow runs or a bug report. Turn it off afterwards.
Written for practice in the style of the exam: never a question from the real exam.
In the course
The lesson Inspecting state and verbose logging teaches this objective (about 45 minutes), and 18 practice questions test it. The course has lessons, exam-style questions, timed practice exams and an AI tutor for every objective, and a pass prediction that tells you when you're ready to book.