Question 351 of 519
Implement and maintain statemediumMultiple ChoiceObjective-mapped

Quick Answer

The answer is to run terraform force-unlock with the lock ID. This is the correct approach because Terraform Cloud uses a locking mechanism on the remote backend to prevent concurrent state modifications and corruption; when a terraform apply fails, the lock persists as a safety measure, and the force-unlock command is the only built-in way to override that lock without bypassing Terraform’s integrity checks. On the HashiCorp Terraform Associate TF-003 exam, this question tests your understanding of state management and backend safety—a common trap is assuming you can delete or manually edit the state file, which would risk data loss and is explicitly discouraged. Instead, remember that you must first retrieve the lock ID from the error message or Terraform Cloud UI, then run terraform force-unlock <LOCK_ID>. A helpful memory tip: think of it as a “safety key” for a stuck lock—never force the file, only force the lock.

TF-003 Implement and maintain state Practice Question

This TF-003 practice question tests your understanding of implement and maintain state. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

A team is using a remote backend in Terraform Cloud. After a failed apply, the state file is locked. The team lead wants to unlock the state immediately. What should be done?

Clue words in this question

Noticing these words before you look at the options changes how you read each choice.

  • Clue: "immediately / without restart"

    Why it matters: Time or reboot constraint — the correct answer must take effect right away without requiring a reboot or reload.

Question 1mediummultiple choice
Full question →

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

Run terraform force-unlock with the lock ID

The `terraform force-unlock` command with the lock ID is the correct way to manually unlock a state file in Terraform Cloud after a failed apply. This command overrides the backend's lock mechanism, which is designed to prevent concurrent modifications and state corruption. Deleting or editing the state file would bypass Terraform's safety guarantees and risk data loss or inconsistency.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

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

  • Delete the state file from the backend and reinitialize

    Why it's wrong here

    Deleting the state file is destructive and can cause data loss.

  • Run terraform force-unlock with the lock ID

    Why this is correct

    The terraform force-unlock command with the lock ID manually releases the lock.

    Clue confirmation

    The clue word "immediately / without restart" in the question point toward this answer.

    Related concept

    Read the scenario before looking for a memorised answer.

  • Manually edit the state file to remove the lock

    Why it's wrong here

    Editing the state file directly is risky and not recommended.

  • Run terraform unlock

    Why it's wrong here

    There is no terraform unlock command; the correct command is terraform force-unlock.

Common exam traps

Common exam trap: answer the scenario, not the keyword

The trap here is that candidates may confuse `terraform force-unlock` with a non-existent `terraform unlock` command, or mistakenly think that deleting or editing the state file is a valid workaround, when in fact Terraform's state locking is enforced at the backend API level and requires the proper command with the lock ID.

Trap categories for this question

  • Command / output trap

    There is no terraform unlock command; the correct command is terraform force-unlock.

Detailed technical explanation

How to think about this question

Terraform Cloud uses a distributed locking mechanism via its backend API, where each lock is associated with a unique lock ID generated at the start of an operation. The `force-unlock` command sends an HTTP DELETE request to the backend's lock endpoint, bypassing the normal lock-holder check. In real-world scenarios, a stale lock can occur if a Terraform process crashes or a network interruption leaves the lock held, and using `force-unlock` is the only safe way to release it without manual backend intervention.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A practitioner preparing for the TF-003 exam encounters this exact type of scenario on the job. The correct answer here is not the most general option — it is the best answer for the specific constraint described. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Real exam questions reward reading the full scenario before eliminating options, because the constraint defines which answer fits.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related TF-003 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free TF-003 practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this TF-003 question test?

Implement and maintain state — This question tests Implement and maintain state — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: Run terraform force-unlock with the lock ID — The `terraform force-unlock` command with the lock ID is the correct way to manually unlock a state file in Terraform Cloud after a failed apply. This command overrides the backend's lock mechanism, which is designed to prevent concurrent modifications and state corruption. Deleting or editing the state file would bypass Terraform's safety guarantees and risk data loss or inconsistency.

What should I do if I get this TF-003 question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Are there clue words in this question I should notice?

Yes — watch for: "immediately / without restart". Time or reboot constraint — the correct answer must take effect right away without requiring a reboot or reload.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

4 more ways this is tested on TF-003

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. A team is using a shared backend for Terraform state. After running terraform apply, the state file is locked for an extended period, causing other team members to fail with 'Error acquiring the state lock'. What is the most likely cause?

easy
  • A.A previous terraform apply command was interrupted or crashed, leaving a stale lock.
  • B.Another team member is actively running terraform apply on the same state.
  • C.The backend configuration was changed without running terraform init.
  • D.The state file contains resources that no longer exist in the cloud provider.

Why A: Option A is correct because Terraform uses a locking mechanism (typically via DynamoDB for AWS S3 backends) to prevent concurrent state modifications. If a `terraform apply` is interrupted or crashes, the lock may not be released, leaving a stale lock entry. This causes subsequent operations to fail with 'Error acquiring the state lock' until the lock is manually removed or expires (if TTL is configured).

Variation 2. A team uses an S3 backend for Terraform state. During a `terraform apply`, another team member accidentally runs a plan that also modifies the same state. Which feature prevents state corruption in this scenario?

easy
  • A.The `-lock=false` flag
  • B.Terraform Cloud remote operations
  • C.State locking via DynamoDB
  • D.State versioning in S3

Why C: State locking prevents concurrent modifications to the state file. Options A and C are not related to state locking. Option D is not a built-in feature.

Variation 3. During a deployment, a user runs `terraform apply` but the command fails because the state lock cannot be acquired. They suspect the lock was released after the previous `apply` but is still held. What command can they use to force unlock the state?

medium
  • A.`terraform init -force-copy`
  • B.`terraform force-unlock <lock_id>`
  • C.`terraform state unlock`
  • D.`terraform break-lock`

Why B: `terraform force-unlock` is the command to manually release a stuck lock. Option B correct. Options A, C, D are not valid or not intended for this purpose.

Variation 4. Refer to the exhibit. A developer runs `terraform apply` but receives an error that the state file is locked. Which of the following is a likely cause?

medium
  • A.The DynamoDB table for locking is not configured
  • B.The S3 bucket does not exist
  • C.The IAM user lacks s3:ListBucket permission
  • D.The encryption key is incorrect
  • E.Another user has an active plan or apply running

Why E: A state lock error typically occurs when another process (e.g., another user's plan or apply) is currently holding the lock. Other issues like bucket existence or permissions would cause different errors.

Last reviewed: Jun 11, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This TF-003 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-003 exam.