TA-002-P · Question #152
You have created 2 workspaces PROD and RQ
The correct answer is A. You have switched to RQA and provisioned RQA infrastructure from this workspace. When using Terraform local workspaces, each non-default workspace stores its state file in a subdirectory under terraform.tfstate.d/, isolated from other workspaces.
Question
You have created 2 workspaces PROD and RQ
Options
- AYou have switched to RQA and provisioned RQA infrastructure from this workspace.
- Bterraform.tfstate.d
- Cterraform.d
- Dterraform.tfstate.RQA
- Eterraform.tfstate
How the community answered
(59 responses)- A83% (49)
- B2% (1)
- C2% (1)
- D10% (6)
- E3% (2)
Why each option
When using Terraform local workspaces, each non-default workspace stores its state file in a subdirectory under terraform.tfstate.d/, isolated from other workspaces.
After switching to the RQA workspace with terraform workspace select and running terraform apply, Terraform provisions the infrastructure under that workspace context and records state in terraform.tfstate.d/RQA/terraform.tfstate, keeping it fully isolated from the default and other named workspaces.
terraform.tfstate.d is the parent directory that contains subdirectories for each named workspace - it is not itself the state file path for the RQA workspace.
terraform.d is a directory reserved for plugin caching and local provider installations, and has no role in storing workspace state files.
terraform.tfstate.RQA is not a valid path - Terraform uses the nested structure terraform.tfstate.d/RQA/terraform.tfstate, not a flat dotted filename.
terraform.tfstate stores state only for the default workspace - named workspaces like RQA never read or write to this file.
Concept tested: Terraform local workspace state file directory structure
Source: https://developer.hashicorp.com/terraform/language/state/workspaces
Topics
Community Discussion
No community discussion yet for this question.