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

Prepare for the HashiCorp Terraform Associate Exam with quizzes, flashcards, and multiple-choice questions. Each question includes hints and explanations. Boost your confidence and ace your exam!

Multiple Choice

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

Explanation:
Terraform keeps a state file that represents the real resources it manages. When you destroy something outside Terraform, the state becomes out of sync. In a normal plan, Terraform refreshes its state against the actual infrastructure, so if a resource has been manually destroyed, the refresh detects that the resource no longer exists and updates the state accordingly. Because this refresh happens automatically during plan (and again during apply), there’s no need to manually edit the state or import the resource. The best practice is to rely on this automatic drift detection and state update, which keeps Terraform aligned with reality without extra steps.

Terraform keeps a state file that represents the real resources it manages. When you destroy something outside Terraform, the state becomes out of sync. In a normal plan, Terraform refreshes its state against the actual infrastructure, so if a resource has been manually destroyed, the refresh detects that the resource no longer exists and updates the state accordingly. Because this refresh happens automatically during plan (and again during apply), there’s no need to manually edit the state or import the resource. The best practice is to rely on this automatic drift detection and state update, which keeps Terraform aligned with reality without extra steps.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy