In Terraform deployments to Azure, which statement about state files is true?

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

In Terraform deployments to Azure, which statement about state files is true?

Explanation:
Terraform state is the single source of truth for your deployed infrastructure. If a resource managed by Terraform is changed outside Terraform (for example, in the Azure Console), the state becomes out of sync. On the next plan (or apply), Terraform refreshes the state by querying Azure to capture the real, current attributes of the resources and writes that live state back to the state file. This is why the statement about updating the state file to reflect the external change during the next plan or apply is true. After that refresh, Terraform will show any drift relative to your configuration and, when you apply, will reconcile as needed and update the state again. The other options misrepresent how Terraform handles external changes: state isn’t updated automatically without a plan/refresh, there isn’t a concept of creating a new state file for a single change, and the current state file can be updated when you plan or apply after the external change.

Terraform state is the single source of truth for your deployed infrastructure. If a resource managed by Terraform is changed outside Terraform (for example, in the Azure Console), the state becomes out of sync. On the next plan (or apply), Terraform refreshes the state by querying Azure to capture the real, current attributes of the resources and writes that live state back to the state file. This is why the statement about updating the state file to reflect the external change during the next plan or apply is true. After that refresh, Terraform will show any drift relative to your configuration and, when you apply, will reconcile as needed and update the state again. The other options misrepresent how Terraform handles external changes: state isn’t updated automatically without a plan/refresh, there isn’t a concept of creating a new state file for a single change, and the current state file can be updated when you plan or apply after the external change.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy