Domain 3 of 8 · Chapter 6 of 7

Destroy managed infrastructure

Unlock the complete study guide + 1,040 practice questions across 16 full exams.

Bundled into the existing HashiCorp Certified: Terraform Associate premium course — no separate purchase.

14-day money-back guarantee — no questions asked.

Included in this chapter:

  • What destroy does: apply in destroy mode
  • Scoping, previewing, and skipping approval
  • Guarding resources with prevent_destroy
  • Exam-pattern recognition

Three ways to invoke the destroy planning mode

Aspectterraform destroyterraform apply -destroyterraform plan -destroy
What it isConvenience alias for apply -destroyApply run in destroy planning modePlan run in destroy planning mode
Changes real infrastructure?Yes, after approvalYes, after approvalNo, it is a preview only
Prompts for approval?Yes, unless -auto-approveYes, unless -auto-approveNo prompt; nothing is applied
Default scopeAll managed objectsAll managed objectsAll managed objects
Narrow with -target?YesYesYes

Decision tree

Preview only, no deletion?terraform plan -destroypreview; nothing removedYesNoRemove only some resources?terraform destroy -targetchosen instances + dependentsYesNoAutomated, no approver?terraform destroy -auto-approveskips the yes promptYesNoterraform destroyreview plan, type yes

Cheat sheet

  • destroy is an alias for apply -destroy
  • destroy accepts apply options but no plan file
  • destroy removes all managed objects
  • destroy can be scoped or previewed
  • prevent_destroy blocks destruction

Unlock with Premium — includes all practice exams and the complete study guide.

References

  1. Command: destroy
  2. Command: plan
  3. Command: apply
  4. The lifecycle Meta-Argument