TF-Associate-004 domain - 11% of the exam

Terraform state management

Terraform state management is 11% of the HashiCorp Certified: Terraform Associate (TF-Associate-004) exam. These are the objectives it covers, each with practice questions, with every answer explained.

Objectives in this domain

Sample question from this domain

Free sampleTerraform state managementeasy

A practitioner runs 'terraform apply' in a new directory that contains only 'main.tf', with no 'backend' or 'cloud' block declared. After the apply succeeds, where does Terraform record the resulting state by default?

terraform {
  required_providers {
    local = {
      source = "hashicorp/local"
    }
  }
}
resource "local_file" "note" {
  filename = "${path.module}/note.txt"
  content  = "hello"
}
  • AIn a file named 'terraform.tfstate' in the current working directory, using the local backend. Correct
  • BIn HCP Terraform, because any workspace is automatically linked to the remote state service.
  • CIn the provider's own datastore, since the 'local' provider manages where state is persisted.
  • DNowhere on disk, because state is held only in memory until a backend is added.
When no backend is configured, Terraform defaults to the local backend and stores state in terraform.tfstate on disk. The local backend is Terraform's built-in default. When neither a 'backend' nor a 'cloud' block is present, Terraform persists the working state to a file called terraform.tfstate in the current directory after every successful operation.

Why A is correct: With no backend or cloud block configured, Terraform uses the local backend by default and writes state to 'terraform.tfstate' in the working directory.

Why B is wrong: HCP Terraform is only used when a 'cloud' block is present; without one Terraform never links a workspace to a remote service, so this is wrong.

Why C is wrong: It is tempting to conflate the 'local' provider with the local backend, but providers manage resources and never decide where state is stored.

Why D is wrong: Terraform always persists state after an apply; the default local backend writes it to disk immediately rather than keeping it only in memory.

Other domains in this exam

See also the TF-Associate-004 cert hub, the study guide, and the cheat sheet.

Examworthy is not affiliated with or endorsed by HashiCorp. Original, blueprint-aligned practice material only.