HashiCorp Terraform Associate (004) Question 217
Single answer8c Describe how to organize and use HCP Terraform workspaces and projectsA platform team is migrating from local Terraform execution to HCP Terraform. They support three application teams, and each application has separate development, staging, and production environments. The platform lead wants a structure that makes it easy to group related work, apply team-level access controls, and keep runs isolated per environment. Which approach is the MOST appropriate?
- A
Create one HCP Terraform project for each application, and place separate workspaces for development, staging, and production inside that project's application-specific project.
- B
Create one HCP Terraform workspace for each application, and use Terraform workspaces inside the configuration to represent development, staging, and production environments.
- C
Create one HCP Terraform project for each environment, and place all applications for that environment into a single shared workspace.
- D
Create a single HCP Terraform project and a single HCP Terraform workspace for all applications and environments, then use variable sets to distinguish between teams and stages.
Show answer and explanation
Correct answer: A
Explanation
The key concept is that HCP Terraform projects are organizational containers for workspaces, while workspaces are where Terraform runs execute and state is stored. For real-world use, separate environments such as development, staging, and production should usually be modeled as separate HCP Terraform workspaces so each environment has isolated state, variables, run history, and policy application. Projects help teams group related workspaces, improve discoverability, and support access management patterns. A common best practice is to organize workspaces by application or service within a project, then create separate workspaces for each environment. Candidates should also recognize the distinction between HCP Terraform workspaces and Terraform CLI workspaces; they are different features and should not be treated as interchangeable. This aligns with HashiCorp guidance on using projects to organize workspaces and on using HCP Terraform workspaces as the primary unit of execution and state isolation.
- A. Correct.
Correct. In HCP Terraform, projects are used to organize related workspaces, and workspaces are the unit where runs, state, variables, and execution are isolated. Creating one project per application allows the platform team to group each application's environments together and apply access controls and organization more cleanly. Using separate workspaces for development, staging, and production aligns with best practice because each environment gets its own state and run history.
- B. Incorrect.
Incorrect. This confuses HCP Terraform workspaces with Terraform CLI workspaces. In HCP Terraform, the recommended pattern for separate environments is typically separate HCP Terraform workspaces, not a single workspace that relies on Terraform CLI workspaces internally. A single HCP Terraform workspace would share run context and make environment-level isolation and governance harder.
- C. Incorrect.
Incorrect. While projects can group workspaces, putting all applications in one shared workspace per environment is not appropriate because a workspace is intended to manage a single state for a specific configuration context. Combining multiple applications into one workspace reduces isolation, increases blast radius, and makes ownership and run management more difficult.
- D. Incorrect.
Incorrect. A single project can technically contain many workspaces, but a single workspace for all applications and environments is poor design. Variable sets do not replace the need for separate state and run isolation. This design would make changes risky, complicate approvals, and prevent clean separation between teams and environments.