Courseiva
Implement and maintain stateeasyMultiple ChoiceObjective-mapped

TF-004 Implement and maintain state Practice Question

A user runs `terraform apply` and receives an error: 'Error acquiring the state lock'. What is the most likely cause?

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Another user is running a Terraform command that modifies state.

The error 'Error acquiring the state lock' means that another operation currently holds the lock on the state file. Option A is correct because if another user is running a Terraform command that modifies state (such as apply or destroy), the lock will be acquired and subsequent operations will fail. Option B is incorrect because a missing state file would produce a different error (e.g., 'No state file found'). Option C is incorrect because invalid backend configuration is caught during 'terraform init', not during 'apply'. Option D is incorrect because provider incompatibility typically leads to plugin-related errors, not state lock errors.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Another user is running a Terraform command that modifies state.

    Why this is correct

    When multiple Terraform operations attempt to modify the state file concurrently, Terraform employs a state locking mechanism to prevent corruption. If one user initiates a command like `terraform apply` or `terraform destroy` that acquires the state lock, any subsequent operation attempting to modify the state will encounter an "error acquiring state lock" message. This ensures data integrity by serializing state-modifying actions, preventing race conditions and inconsistent infrastructure deployments.

  • The state file is missing.

    Why it's wrong here

    If the Terraform state file is entirely missing, either locally or in the configured remote backend, Terraform would typically report an error indicating that no state was found or that the backend is uninitialized. This scenario does not trigger a state lock error, as there is no existing state to lock or contend with. Instead, the error message would likely prompt the user to initialize the backend or indicate that no resources are managed.

  • The backend configuration is invalid.

    Why it's wrong here

    An invalid backend configuration, such as incorrect S3 bucket names, authentication credentials, or endpoint URLs, would typically manifest as an error during the `terraform init` command. This command is responsible for initializing the working directory, configuring the backend, and downloading providers. If the backend configuration is malformed or inaccessible, `terraform init` would fail, preventing `terraform apply` from even attempting to acquire a state lock.

  • The Terraform provider is incompatible.

    Why it's wrong here

    An incompatibility with a Terraform provider, such as a version mismatch between the provider and the Terraform core, or a corrupted provider plugin, would typically result in a "plugin error" or "provider not found" message. These errors occur when Terraform attempts to load or interact with the provider to plan or apply changes. Such issues are distinct from state locking problems, which relate to concurrent access to the state file itself, not the underlying resource management logic.

About these practice questions

One of 428 original TF-004 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This TF-004 practice question is part of Courseiva's free HashiCorp certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the TF-004 exam.