If you manually destroy infrastructure, what is the best practice to reflect this change in Terraform?

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 manually destroy infrastructure, what is the best practice to reflect this change in Terraform?

Explanation:
When infrastructure is destroyed outside Terraform, your state and real world drift apart. The right move is to tell Terraform you’ll no longer manage that resource and then refresh the state to reflect the new reality, without performing any changes. Removing the resource from your configuration communicates that you don’t want Terraform to manage it anymore, and running an apply with the refresh-only option updates Terraform’s state to match what actually exists now, without recreating or destroying anything. Directly editing the state file is risky and not recommended, Terraform won’t update itself automatically, and importing would only bring a resource back under management rather than reflect that it was manually destroyed.

When infrastructure is destroyed outside Terraform, your state and real world drift apart. The right move is to tell Terraform you’ll no longer manage that resource and then refresh the state to reflect the new reality, without performing any changes. Removing the resource from your configuration communicates that you don’t want Terraform to manage it anymore, and running an apply with the refresh-only option updates Terraform’s state to match what actually exists now, without recreating or destroying anything. Directly editing the state file is risky and not recommended, Terraform won’t update itself automatically, and importing would only bring a resource back under management rather than reflect that it was manually destroyed.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy