nerdexam
HashiCorp

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…

Implement and maintain state

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)
  • A
    3% (1)
  • B
    3% (1)
  • C
    88% (30)
  • D
    6% (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.

AA state file represents a source of truth for resources provisioned with a public cloud console

The state file tracks resources provisioned by Terraform, not those managed directly through a public cloud console, which Terraform is unaware of until imported.

BA state file represents a source of truth for resources provisioned with Terraform

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.

CA state file represents the desired state expressed by the Terraform code filesCorrect

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.

DA state file can be used to schedule recurring infrastructure tasks

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

#Terraform State#State File#Desired State

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice