Which file stores the Terraform state locally?

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

Which file stores the Terraform state locally?

Explanation:
Terraform keeps a local state file that tracks what it manages and how resources map to real-world objects. By default, when you don’t configure a different backend, Terraform writes this state to a file named terraform.tfstate in your working directory. This file is JSON and includes resource addresses, IDs assigned by providers, and current attributes and dependencies, which is what allows Terraform to plan changes accurately and reconcile drift. A backup of the previous state is kept as terraform.tfstate.backup. If you configure a remote backend (like S3, Consul, etc.), the state is stored remotely, and there isn’t a local terraform.tfstate file. The other file name options don’t match Terraform’s local-state convention, so terraform.tfstate is the correct choice.

Terraform keeps a local state file that tracks what it manages and how resources map to real-world objects. By default, when you don’t configure a different backend, Terraform writes this state to a file named terraform.tfstate in your working directory. This file is JSON and includes resource addresses, IDs assigned by providers, and current attributes and dependencies, which is what allows Terraform to plan changes accurately and reconcile drift. A backup of the previous state is kept as terraform.tfstate.backup. If you configure a remote backend (like S3, Consul, etc.), the state is stored remotely, and there isn’t a local terraform.tfstate file. The other file name options don’t match Terraform’s local-state convention, so terraform.tfstate is the correct choice.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy