TERRAFORM-ASSOCIATE-003 practice question 26 of 30
[Understand Terraform Basics and CLI] When should you use the force-unlock command?
Full set: 226 questionsThe terraform force-unlock command is a manual intervention tool designed for exceptional circumstances where Terraform's automatic state locking mechanism fails. This typically occurs if a Terraform process is interrupted or crashes, leaving behind a "stale" lock on the state file. This stale lock prevents other Terraform operations from proceeding. The force-unlock command allows an operator to manually remove this lock after verifying that no other process is actively and legitimately modifying the state, thereby preventing potential state file corruption.
A. A change's priority is a business concern, not a technical justification for bypassing a critical safety feature like state locking, which could corrupt your state.
C. An apply failing due to a lock is a symptom, not the root cause. The lock might be held by another user's valid operation; investigation is required before forcing an unlock.
D. This message indicates normal locking behavior. The correct action is to wait for the existing operation to complete or coordinate with the team, not to forcibly break the lock. ---
1. HashiCorp Terraform Documentation, "State Locking": "If a command is interrupted, it may leave a stale lock file behind. You can use the force-unlock command to manually remove a stale lock file." This directly supports that the command is for situations where the automatic process (releasing the lock upon completion) has failed.
2. HashiCorp Terraform Documentation, "Command: force-unlock": "This command will remove the lock on the state for the current configuration. This will not modify your infrastructure. This is a last resort, and should only be used if you are sure that no other instance of Terraform is running." This emphasizes its use as a last resort, characteristic of a failure scenario.
3. HashiCorp Learn, "Lock and Unlock State": "In some cases, a Terraform process may exit without releasing its lock, for example if the process is killed or the machine running it crashes. In this case, you will need to manually unlock the state... To do this, run the terraform force-unlock command". This explicitly links the command's use to abnormal process termination where automatic unlocking fails.
Keep practicing
Take the free TERRAFORM-ASSOCIATE-003 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other TERRAFORM-ASSOCIATE-003 practice questions
- Question 1[Understand Terraform Basics and CLI] If you update the version constraint in your Terraf…
- Question 2[Navigate Terraform State and Backends] Terraform variable names are saved in the state f…
- Question 3[Understand Terraform Basics and CLI] You modified your Terraform configuration and run T…
- Question 4[Understand Terraform Basics and CLI] You must use different Terraform commands depending…
- Question 6[Understand Terraform Basics and CLI] terraform init creates an example main.tf file in t…
- Question 7[Understand Terraform Basics and CLI] terraform validate confirms that your infrastructur…
