HashiCorp Certified: Terraform Associate (003) — Question 21
You 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 Terraform will delete.
Which command should you use to show all the resources that will be deleted? (Choose two.)
Answer options
- A. Run terraform state rm *.
- B. Run terraform destroy.This will output all the resources that will be deleted before prompting for approval.
- C. Run terraform plan -destroy.
- D. Run terraform show -destroy.
Correct answer: B, C
Explanation
The correct answer is B and C. Option B, 'terraform destroy', provides a detailed output of the resources that will be deleted and requests user confirmation, ensuring safety. Option C, 'terraform plan -destroy', shows a preview of what will be removed without making any changes. Options A and D do not fulfill the requirement as they either remove state entries or are not valid commands for previewing deletions.