If you remove a resource from configuration after applying, what happens on next apply?

Prepare for the HashiCorp Terraform Associate Exam. Utilize flashcards and multiple-choice questions with detailed hints and explanations. Boost your confidence and be ready for success!

Multiple Choice

If you remove a resource from configuration after applying, what happens on next apply?

Explanation:
This tests how Terraform reconciles the real world with your configuration using state as the truth. Terraform keeps a state file that records what actually exists. The configuration defines the desired end state. If you remove a resource from the configuration but it still exists in state, Terraform sees drift—the resource is present but not described in your config. On the next apply, Terraform plans to destroy that resource so the real infrastructure matches the configuration. Therefore, the virtual machine will be destroyed during apply. If you wanted to keep the VM, you’d either re-add it to the configuration or remove it from the state (for example, with a state rm) after confirming you no longer want Terraform to manage it.

This tests how Terraform reconciles the real world with your configuration using state as the truth. Terraform keeps a state file that records what actually exists. The configuration defines the desired end state. If you remove a resource from the configuration but it still exists in state, Terraform sees drift—the resource is present but not described in your config. On the next apply, Terraform plans to destroy that resource so the real infrastructure matches the configuration. Therefore, the virtual machine will be destroyed during apply.

If you wanted to keep the VM, you’d either re-add it to the configuration or remove it from the state (for example, with a state rm) after confirming you no longer want Terraform to manage it.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy