Resuming a Failed Terraform Apply Without Destroying Resources
During a `terraform apply`, the operation fails mid-way due to a network outage, leaving some resources created. The operator wants to resume applying from where it left off without destroying the already-created resources. What should they do?
Quick Answer
The correct answer is to run terraform apply again. This works because Terraform maintains a state file that records every resource it manages; when an apply fails mid-way, the state file is updated to reflect only the resources that were successfully created, not the ones that failed. Running terraform apply again causes Terraform to compare the current state against your configuration, detect that the already-created resources exist, and proceed to create only the remaining resources—effectively resuming the failed apply without destroying anything. On the HashiCorp Terraform Associate TF-003 exam, this scenario tests your understanding of Terraform’s state-driven workflow and the idempotent nature of apply; a common trap is assuming you must run terraform destroy first or manually roll back, but Terraform’s state file makes that unnecessary. Memory tip: “State saves the day—apply again, no need to slay.”
⚠ Common exam trap
Watch out — candidates often think a failed apply requires a full destroy or refresh, but Terraform's state-driven design allows idempotent resumption, and the exam tests understanding that `terraform apply` is the correct command to re-run after any partial failure.
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 apply again
Terraform uses a state file to track the resources it manages. When `terraform apply` fails mid-way, the state file is updated to reflect the resources that were successfully created. Running `terraform apply` again will cause Terraform to compare the current state with the configuration, detect that the already-created resources exist, and proceed to create only the remaining resources, effectively resuming from where it left off without destroying anything.
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 apply again
Why this is correct
Running `terraform apply` again reconciles actual infrastructure against the state file, creating only the missing resources and leaving existing ones untouched. Terraform's declarative model makes this idempotent, satisfying the stem's requirement to resume without destroying already-created resources after the network outage interrupted the operation.
- ✗
Run terraform destroy and then apply
Why it's wrong here
Destroying removes the resources already created, directly contradicting the requirement to preserve them and resume. It is tempting because destroy-then-apply guarantees a clean, known state, which would be correct in a disposable test environment where no data or dependencies must survive.
- ✗
Run terraform refresh
Why it's wrong here
Refresh only reconciles state with real infrastructure; it never creates the resources still missing after the outage. It is tempting because refresh is the standard way to correct drift before planning, which would be right if state merely disagreed with existing resources rather than lacking unbuilt ones.
- ✗
Run terraform apply -auto-approve
Why it's wrong here
Auto-approve only skips the interactive confirmation prompt; it does not alter how Terraform reconciles partial state, so the same plan executes. It is tempting because it removes a manual step during recovery, and would suit automated CI pipelines where no operator is present to confirm.
Go deeper
Related to this question
About these practice questions
One of 434 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 →
Same concept, more angles
1 more way this is tested on TF-004
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. During a CI/CD pipeline run, terraform apply fails halfway through due to a network error. The state file is locked. The team wants to resume from the last successful apply. What should they do?
hard- ✓ A.Re-run terraform apply after solving the network issue; Terraform will handle partial state.
- B.Run terraform destroy and then reapply.
- C.Force unlock the state and then reapply.
- D.Manually delete the partially created resources in the cloud console and reapply.
Why A: Terraform's state file tracks all managed resources and their current status. When `terraform apply` fails mid-run, the state is locked to prevent corruption, but Terraform records any resources that were successfully created before the failure. After resolving the network issue, re-running `terraform apply` will use the existing state to detect already-created resources and continue from where it left off, creating only the remaining resources. This is the correct and intended workflow for handling partial state in Terraform.
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.