nerdexam
HashiCorp

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.

Implement and maintain state

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)
  • A
    2% (1)
  • B
    7% (3)
  • C
    88% (37)
  • D
    2% (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.

AIt uses a different branch of code

Workspaces operate on the same codebase; using a different branch would typically imply a different version of the configuration, not just a different workspace.

BIt uses a different backend

Workspaces share the same backend configuration, but within that backend, each workspace gets its own isolated state.

CIt has its own state fileCorrect

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.

DIt pulls in a different terraform.tvars file

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

#Terraform workspaces#State management#Environment isolation

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice