TA-002-P · Question #357
You have decided to create a new Terraform workspace to deploy a development environment. What is different about this workspace?
The correct answer is C. It has its own state file. Each Terraform workspace manages its own isolated state file, allowing different environments (like development, staging, production) to be deployed from the same configuration.
Question
You have decided to create a new Terraform workspace to deploy a development environment. What is different about this workspace?
Options
- AIt uses a different branch of code
- BIt uses a different backend
- CIt has its own state file
- DIt pulls in a different terraform.tvars file
How the community answered
(42 responses)- A2% (1)
- B7% (3)
- C88% (37)
- D2% (1)
Why each option
Each Terraform workspace manages its own isolated state file, allowing different environments (like development, staging, production) to be deployed from the same configuration.
Workspaces operate on the same codebase; using a different branch would typically imply a different version of the configuration, not just a different workspace.
Workspaces share the same backend configuration, but within that backend, each workspace gets its own isolated state.
Terraform workspaces, by design, maintain separate state files for each workspace within the same backend, enabling the deployment of multiple, isolated instances of the same infrastructure configuration without interference. This allows for managing different environments like dev, staging, and prod using the same set of Terraform configuration files.
While you might use different `terraform.tfvars` files with different workspaces, this is a common practice, not an inherent difference about the workspace itself; the core difference is the state file.
Concept tested: Terraform workspaces and state management
Source: https://developer.hashicorp.com/terraform/cli/commands/workspace
Topics
Community Discussion
No community discussion yet for this question.