CertLumen

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 list shows addresses (filter by address or -id=); terraform state show ADDRESS shows one resource's attributes
  • terraform show prints the whole state or a saved plan file; -json is 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 mv rebinds an object to a new address (rename or move into a module); moved blocks are the declarative equivalent
  • state rm forgets an object without destroying it; the removed block with destroy = false does the same declaratively

Try a question

When is turning on verbose logging with TF_LOG most appropriate?

  1. AEvery time a configuration is applied in production, so that traces are always available
  2. BWhen troubleshooting an unexplained provider error or writing a bug report
  3. CTo store a permanent audit trail of every change made to the infrastructure
  4. 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.

More in this section

← Previous objective · All 37 objectives · Next objective →