004 · Domain 6: Terraform state management · 13% of the exam
Task 6.1: Describe the local backend
The default backend: state in terraform.tfstate on local disk, the backup file, workspaces under terraform.tfstate.d, the path argument, and why it does not suit a team.
Study it
The local backend: files, backups and workspaces
Lesson coming
Sample questions
Try each one before opening the answer. Every option is explained, with the HashiCorp documentation page that proves it.
Question 1 · choose 1
A developer uses the default local backend and creates CLI workspaces named dev and test in addition to default. Where does Terraform keep the dev workspace's state?
AIn terraform.tfstate, as a separate section labeled dev
BIn terraform.tfstate.d/dev/terraform.tfstate
CIn .terraform/workspaces/dev.tfstate, managed by terraform init
DIn the dependency lock file, under a workspace "dev" entry
Show the answer and why
AIn terraform.tfstate, as a separate section labeled dev
Incorrect
Each non-default workspace has its own state file in its own directory.
BIn terraform.tfstate.d/dev/terraform.tfstate
Correct
The local backend keeps the default workspace in terraform.tfstate and other workspaces under the terraform.tfstate.d directory.
CIn .terraform/workspaces/dev.tfstate, managed by terraform init
Incorrect
.terraform holds providers, modules and backend settings, not workspace states.
DIn the dependency lock file, under a workspace "dev" entry
Incorrect
The lock file has no workspace entries and never holds state.
With the local backend, default lives in terraform.tfstate and every other workspace in terraform.tfstate.d/<name>/.