nerdexam
HashiCorp

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.

Use the Terraform CLI (terraform plan, apply, destroy, fmt, init, validate, workspace, import, taint, providers, output)

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)
  • A
    83% (49)
  • B
    2% (1)
  • C
    2% (1)
  • D
    10% (6)
  • E
    3% (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.

AYou have switched to RQA and provisioned RQA infrastructure from this workspace.Correct

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.

Bterraform.tfstate.d

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.

Cterraform.d

terraform.d is a directory reserved for plugin caching and local provider installations, and has no role in storing workspace state files.

Dterraform.tfstate.RQA

terraform.tfstate.RQA is not a valid path - Terraform uses the nested structure terraform.tfstate.d/RQA/terraform.tfstate, not a flat dotted filename.

Eterraform.tfstate

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

#Terraform Workspaces#Terraform CLI#Infrastructure Provisioning

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice