HashiCorp Certified: Terraform Associate — Question 340

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, and 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: B

Explanation

When you remove the resource definition from the Terraform configuration and run terraform apply again, Terraform will recognize that the resource no longer exists in the configuration and will proceed to destroy it. The other options are incorrect because 'Nothing' would imply the resource still exists in some form, 'error' would indicate a problem, and 'removal from the state file' suggests the resource would still be active, which it won't be.