HashiCorp Certified: Terraform Associate — Question 20
You have used Terraform to create an ephemeral development environment in the cloud and are now ready to destroy all the infrastructure described by your
Terraform configuration. To be safe, you would like to first see all the infrastructure that will be deleted by Terraform.
Which command should you use to show all of the resources that will be deleted? (Choose two.)
Answer options
- A. Run terraform plan -destroy.
- B. This is not possible. You can only show resources that will be created.
- C. Run terraform state rm *.
- D. Run terraform destroy and it will first output all the resources that will be deleted before prompting for approval.
Correct answer: A, D
Explanation
The correct answers are A and D. Running 'terraform plan -destroy' allows you to see what resources will be deleted, while 'terraform destroy' lists the resources prior to deletion and prompts for confirmation. Option B is incorrect because it is possible to preview resources for deletion, and option C does not show what will be deleted but rather removes resources from the state file.