HashiCorp Certified: Terraform Associate (003) — Question 6

You have a Terraform configuration that defines a single virtual machine with no references to it. You have run terraform apply to create the resource, then removed the resource definition from your Terraform configuration file.
What will happen when you run terraform apply in the working directory again?

Answer options

Correct answer: A

Explanation

The correct answer is A because when the resource definition is removed and terraform apply is executed, Terraform identifies that the resource is no longer defined and proceeds to destroy it. Option B is incorrect because while Terraform does update the state, it does not leave the resource intact; option C is wrong as Terraform handles this scenario without error; and option D is incorrect since the removal of the resource definition triggers a destroy action.