TF-Associate-004 - HCP Terraform (11% of the exam) - Section 8c
Describe how to organize and use HCP Terraform workspaces and projects.
An HCP Terraform workspace has its own state, variables and run history, and projects group related workspaces for organisation and permissions. Candidates should distinguish an HCP Terraform workspace, which holds state, from a Terraform CLI workspace, which switches state within one backend.
HCP Terraform workspaceprojects grouping workspacesworkspace variables and run historyHCP workspace versus CLI workspace
Practice question for this objective
lock_openFree sampleHCP Terraformmedium
A team has one HCP Terraform organisation and wants each of its three environments (dev, staging, production) to keep completely separate state, variable values, and run history, while still being managed through the same VCS-connected setup. How should they structure this in HCP Terraform?
ACreate a single HCP Terraform workspace and switch between the environments using 'terraform workspace new' and 'terraform workspace select' on the CLI.
BCreate three separate HCP Terraform workspaces, one per environment, so each holds its own state, variables, and run history.check_circle Correct
CCreate one HCP Terraform workspace and define three variable sets inside it so the same state is reused across dev, staging, and production.
DCreate one HCP Terraform project and rely on the project to hold three independent states, one for each environment, without adding workspaces.
An HCP Terraform workspace is the unit that isolates state, variables, and run history, so separate environments each need their own workspace. HCP Terraform models each workspace as an independent managed unit with its own state file, variable values, and history of runs, which is why isolating environments is achieved by creating one workspace per environment rather than by CLI workspaces or variable sets.
Why A is wrong: This describes Terraform CLI workspaces, which only switch the state key inside one backend and share the same configuration and run context; it is a different feature from an HCP Terraform workspace and does not give separate run history or variable sets per environment.
Why B is correct: In HCP Terraform the workspace is the unit of isolation: each workspace stores its own state, its own variables, and its own run history, so one workspace per environment gives the separation the team wants.
Why C is wrong: Variable sets can supply different values, but a single workspace still keeps just one state and one run history, so the environments would not be isolated as required.
Why D is wrong: A project is only a grouping container for workspaces and holds no state of its own, so a project without workspaces cannot store any environment state.
Answers that look right on this material and are not. Each one is a distractor from a different question in the TF-Associate-004 bank for this domain.
CLI workspaces created with 'terraform workspace new payments', which collect the related state files under one named group.
errorWhy it is wrong: CLI workspaces only create alternate state keys within a single backend for one configuration; they do not group multiple HCP Terraform workspaces and are a distinct concept.
An HCP Terraform workspace and a CLI workspace are the same feature under two names, differing only in where the command is typed.
errorWhy it is wrong: They share a name but are distinct concepts, so treating them as identical is a common but incorrect assumption.
In the CLI workspace list shown by 'terraform workspace list', which records each run against the selected workspace.
errorWhy it is wrong: 'terraform workspace list' only prints the names of CLI workspaces and holds no record of runs, so it cannot show any run history; this conflates CLI workspaces with HCP Terraform workspaces.