TERRAFORM-ASSOCIATE-003 practice question 28 of 30
[Understand Terraform Basics and CLI] What does state looking accomplish?
Full set: 226 questionsState locking is a fundamental concurrency control mechanism in Terraform. When a Terraform command that can modify the state (e.g., terraform apply, terraform destroy) is initiated, it first attempts to acquire a lock on the state file. If successful, this lock prevents any other Terraform process from running commands that could also modify the state simultaneously. This mechanism is crucial for collaborative environments, as it prevents race conditions, state corruption, and data loss that could occur if multiple users or automated systems tried to update the same state file at the same time.
A. State locking does not prevent file system operations like deletion; it only blocks other Terraform processes from writing to the state.
C. This describes the general process of state persistence after an operation, not the function of locking, which precedes state modification.
D. Locking is for concurrency control, not encryption. State file encryption is a separate feature, often handled by the backend configuration (encryption at rest).
1. HashiCorp Terraform Documentation, "State: Locking": "To prevent this, Terraform has a feature called state locking. When one user is running a state-changing command like terraform apply, Terraform will lock the state. This lock prevents any other user from running a state-changing command at the same time." This directly supports the function of blocking other commands.
2. HashiCorp Terraform Documentation, "Backends: Configuration": In the "State Storage and Locking" section, it is explained that "Most backends support remote state storage and locking." This distinguishes locking as a specific feature for preventing concurrent operations.
3. HashiCorp Terraform Documentation, "Command: apply": The documentation for the apply command states, "Before it can apply any changes, Terraform automatically runs a terraform plan to create an execution plan, and will prompt for your approval before executing it. It will also acquire a state lock to prevent others from making concurrent changes." This confirms that locking is an integral part of commands that modify state.
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…
