HashiCorp Certified: Terraform Associate — Question 269
You have created a main.tr Terraform configuration consisting of an application server, a database, and a load balancer. You ran terraform apply and all resources were created successfully. Now you realize that you do not actually need the load balancer so you run terraform destroy without any flags What will happen?
Answer options
- A. Terraform will destroy the application server because it is listed first in the code
- B. Terraform will prompt you to confirm that you want to destroy all the infrastructure
- C. Terraform will destroy the main.tf file
- D. Terraform will prompt you to pick which resource you want to destroy
- E. Terraform will immediately destroy all the infrastructure
Correct answer: B
Explanation
The correct answer is B, as running 'terraform destroy' without flags will prompt the user for confirmation to destroy all managed resources. Option A is incorrect because the order of resources does not determine which gets destroyed. Option C is not accurate since the main.tf file remains intact. Option D is incorrect as 'terraform destroy' does not provide a selection prompt; it targets all resources unless specified otherwise. Option E is misleading because it implies immediate destruction without confirmation, which is not the case.