Courseiva
Use the core Terraform workflowmediumMultiple ChoiceObjective-mapped

TF-004 Use the core Terraform workflow Practice Question

During a terraform apply, the process crashes mid-way. The state file may be in an inconsistent state. What is the first recommended step to recover?

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 plan.

Terraform plan will show the current state and pending changes, allowing you to diagnose the situation. Option A is wrong because force-unlock is only for lock issues, not state inconsistency. Option B is wrong because re-running apply may fail again or cause further issues. Option D is wrong because terraform destroy would remove all resources, not just the half-created ones.

Answer analysis

Option-by-option breakdown

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

  • Run terraform force-unlock.

    Why it's wrong here

    terraform force-unlock is specifically designed to manually release a stale state lock that was not properly cleared by a previous Terraform operation. While a crash during apply might leave a lock, the primary concern is the integrity of the Terraform state file and the actual infrastructure, which could be in an inconsistent or partially provisioned state. Forcibly unlocking without first assessing the state's consistency or the infrastructure's actual condition risks allowing subsequent operations to proceed on a potentially corrupted foundation, potentially exacerbating the problem.

  • Run terraform apply with -auto-approve.

    Why it's wrong here

    Executing terraform apply -auto-approve immediately after a crash is a dangerous action. The -auto-approve flag bypasses the critical interactive review of the execution plan, preventing the operator from inspecting what Terraform intends to do. This means Terraform would proceed blindly, potentially attempting to re-execute the exact operation that caused the initial crash, or applying an incomplete or incorrect plan derived from a potentially corrupted state file, leading to further instability or unintended infrastructure changes.

  • Run terraform plan.

    Why this is correct

    Running terraform plan is the most appropriate first step after a terraform apply crash. This command safely reads the current Terraform state, compares it against the desired configuration, and then queries the actual remote infrastructure to detect any drift or incomplete changes. The resulting detailed execution plan provides crucial visibility into the current perceived state of resources and precisely what Terraform intends to do, allowing the operator to assess the situation, identify inconsistencies, and formulate a recovery strategy without making any further modifications.

  • Run terraform destroy.

    Why it's wrong here

    terraform destroy is an extreme and irreversible command intended to deprovision all resources defined in the current configuration. After a mid-apply crash, the infrastructure is likely in an unknown, partially provisioned, or inconsistent state. Initiating a destroy operation without first understanding the current state and the extent of the damage is highly aggressive and could lead to the unintended removal of critical or still-functional resources, making recovery significantly more complex or impossible, and does not address the goal of resolving the desired state.

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.