TA-002-P · Question #416
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…
The correct answer is B. Terraform will destroy the virtual machine. If you remove the resource from your config file and the resource is in your state file, terraform will apply the configuration in the config file - which is to delete the resource.
Question
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?
Options
- ANothing
- BTerraform will destroy the virtual machine
- CTerraform will error
- DTerraform will remove the virtual machine from the state file, but the resource will still exist
How the community answered
(50 responses)- A2% (1)
- B92% (46)
- C2% (1)
- D4% (2)
Explanation
If you remove the resource from your config file and the resource is in your state file, terraform will apply the configuration in the config file - which is to delete the resource.
Topics
Community Discussion
No community discussion yet for this question.