Courseiva
Use Terraform outside the core workfloweasyMultiple ChoiceObjective-mapped

TF-004 Use Terraform outside the core workflow Practice Question

Exhibit

Error: Error acquiring the state lock

  on <empty> line 0:
  (source code not available)

ConditionalCheckFailedException: The conditional request failed

Refer to the exhibit. A Terraform plan fails with the error shown. What is the most likely cause?

⚠ Common exam trap

HashiCorp often tests the distinction between state file corruption and state locking errors; the trap here is that candidates may confuse a lock failure with a state file issue, especially when the error message includes DynamoDB references.

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 Terraform run is currently in progress.

The error message indicates that Terraform cannot acquire a state lock. This typically occurs when another Terraform run is already in progress and holds the lock on the state file. Terraform uses a locking mechanism (often via DynamoDB) to prevent concurrent modifications; if a lock is already held, subsequent runs will fail with this error until the lock is released or expires.

Answer analysis

Option-by-option breakdown

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

  • The S3 bucket does not have versioning enabled.

    Why it's wrong here

    S3 bucket versioning is a feature designed for retaining multiple versions of an object, allowing for recovery from accidental deletions or overwrites of state files. However, it does not provide a mechanism for state locking, which is crucial for preventing concurrent Terraform operations. A lock acquisition failure specifically indicates an issue with exclusive access, not with state file history management.

  • The DynamoDB table is not configured correctly.

    Why it's wrong here

    A misconfigured DynamoDB table, such as an incorrect table name, region, or insufficient IAM permissions, would typically result in explicit access denied or resource not found errors when Terraform attempts to interact with it. A 'lock acquisition failed' error, however, implies that Terraform successfully located and attempted to use the locking mechanism, but found the lock already held. This specific error points to an active lock rather than a setup issue.

  • The state file is corrupted.

    Why it's wrong here

    A corrupted state file would manifest as parsing errors or unexpected data format issues when Terraform attempts to read or interpret its contents. The process of acquiring a state lock occurs *before* Terraform attempts to read or modify the state file itself, as it is a prerequisite to ensure data integrity. Therefore, a lock acquisition failure indicates an inability to secure exclusive access, not a problem with the state file's internal structure.

  • Another Terraform run is currently in progress.

    Why this is correct

    When a Terraform operation, such as `plan` or `apply`, is initiated, it first attempts to acquire a state lock to prevent concurrent modifications. If another Terraform process is already running against the same state, it will hold this lock, causing subsequent operations to fail with a 'lock acquisition failed' error. This mechanism ensures state consistency and prevents potential corruption from simultaneous updates.

About these practice questions

Courseiva writes every TF-004 question from scratch — 428 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. 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.