HashiCorp Certified: Terraform Associate — Question 24

You have a simple Terraform configuration containing one virtual machine (VM) in a cloud provider. You run terraform apply and the VM is created successfully.
What will happen if you delete the VM using the cloud provider console, and run terraform apply again without changing any Terraform code?

Answer options

Correct answer: D

Explanation

The correct answer is D because Terraform maintains the desired state defined in the configuration. When the VM is deleted manually, the next terraform apply detects that the VM is missing and will recreate it to match the configuration. Options A, B, and C are incorrect as Terraform does not remove resources from the state file on its own, does not report an error in this scenario, and will make changes to restore the desired state.