HashiCorp Terraform Associate (004) · Section 7 · 8% of the exam
Describe when and how to use verbose logging
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
A company moves from hashicorp/aws to a fork hosted in a private registry. Existing state records the old provider address. What lets them switch the provider recorded for all resources without recreating anything?
- Aterraform state mv hashicorp/aws registry.acme.corp/acme/aws for each resource
- Bterraform providers lock -platform=linux_amd64 registry.acme.corp/acme/aws
- Cterraform init -upgrade
- Dterraform state replace-provider hashicorp/aws registry.acme.corp/acme/aws
Show the answer
D. terraform state replace-provider FROM TO updates state so resources use the new provider source. A backup is always written, and you should then update required_providers and run terraform init.
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.