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>/.
HashiCorp documentation