TA-002-P · Question #334
What is a key benefit of the Terraform state file?
The correct answer is C. A state file represents the desired state expressed by the Terraform code files. The Terraform state file tracks the real-world infrastructure provisioned by Terraform, serving as a critical link between your configuration and deployed resources. It allows Terraform to understand the current actual state of managed infrastructure and compare it against the…
Question
What is a key benefit of the Terraform state file?
Options
- AA state file represents a source of truth for resources provisioned with a public cloud console
- BA state file represents a source of truth for resources provisioned with Terraform
- CA state file represents the desired state expressed by the Terraform code files
- DA state file can be used to schedule recurring infrastructure tasks
How the community answered
(34 responses)- A3% (1)
- B3% (1)
- C88% (30)
- D6% (2)
Why each option
The Terraform state file tracks the real-world infrastructure provisioned by Terraform, serving as a critical link between your configuration and deployed resources. It allows Terraform to understand the current actual state of managed infrastructure and compare it against the desired state defined in your HCL code.
The state file tracks resources provisioned by Terraform, not those managed directly through a public cloud console, which Terraform is unaware of until imported.
While the state file tracks resources provisioned by Terraform, it is not the *source of truth* for the configuration itself; the Terraform code files are the source of truth for the desired state.
The state file records the mapping between your Terraform configuration and the actual resources deployed in your cloud provider, helping Terraform understand what currently exists and how it relates to the desired state defined in your HCL code. Terraform uses this information during `plan` and `apply` operations to determine what changes are necessary to achieve the desired state specified in your configuration.
The Terraform state file's purpose is to manage infrastructure state, not to schedule recurring infrastructure tasks.
Concept tested: Terraform state file purpose
Source: https://developer.hashicorp.com/terraform/language/state
Topics
Community Discussion
No community discussion yet for this question.