HashiCorp Terraform Associate (004) · Section 6 · 10% of the exam
Describe the local backend
One of the objectives of the HashiCorp Certified: Terraform Associate (004) exam, in the section “Terraform state management”. Here is what it covers, the points to remember and a question to try.
What it covers
Terraform keeps a state file that maps your configuration to real objects. This lesson covers the default local backend, how state locking prevents two runs from writing at once, and how to move state to a remote backend with the backend block, partial configuration and terraform init.
Points to remember
- With no backend or cloud block, Terraform uses the local backend and stores state in terraform.tfstate in the working directory.
- The local backend keeps the previous state in terraform.tfstate.backup and non-default workspaces under terraform.tfstate.d.
- Terraform locks state automatically for operations that could write it, if the backend supports locking.
- -lock-timeout waits for a lock; -lock=false skips locking and is not recommended; force-unlock LOCK_ID releases a stale lock.
- S3 native locking is use_lockfile = true (a .tflock object); DynamoDB locking is deprecated.
Try a question
Versioning is not enabled on the S3 bucket that holds production state. An engineer accidentally deletes the state object. What is the consequence, and which practice would have prevented it?
- ATerraform rebuilds state from the provider APIs on the next plan automatically; versioning is only needed for audit purposes
- BTerraform can no longer track the real resources; enabling bucket versioning would have allowed recovery
- CTerraform recreates the state from
terraform.tfstate.backupin the bucket - DThe lock object in the bucket contains a full copy of state
Show the answer
B. State is the only record binding configuration to real objects. If it is lost, the next plan wants to create everything again. HashiCorp strongly recommends bucket versioning for the S3 backend so earlier versions can be restored.
Written for practice in the style of the exam: never a question from the real exam.
In the course
The lesson Local backend, state locking and remote state teaches this objective (about 40 minutes), and 24 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.