HashiCorp Terraform Associate (004) Question 214
Single answer8c Describe how to organize and use HCP Terraform workspaces and projectsA platform team is migrating several Terraform configurations into HCP Terraform. They want to group related workspaces for visibility and access management. Their plan is to create one project for each application domain, such as Payments and Analytics, and then place separate dev, staging, and prod workspaces inside each project. Team leads also want a simple way to view all workspaces related to a domain together without mixing them with unrelated infrastructure. Which approach best meets this requirement using HCP Terraform projects and workspaces?
- A
Create one HCP Terraform project per application domain and place the environment-specific workspaces for that domain inside the same project
- B
Create one workspace per application domain and use Terraform workspaces inside the CLI to represent dev, staging, and prod in HCP Terraform
- C
Create a single HCP Terraform project for the entire organization because projects cannot contain multiple workspaces
- D
Create separate HCP Terraform organizations for Payments and Analytics because projects are only used for VCS connections, not workspace grouping
Show answer and explanation
Correct answer: A
Explanation
The best answer is to use HCP Terraform projects as logical containers for related workspaces. In this scenario, a project per application domain, with separate workspaces for dev, staging, and prod, aligns with how HCP Terraform is designed to organize infrastructure at scale. This approach improves visibility, keeps related workspaces together, and supports clearer management within a single organization. A common misconception is to use Terraform CLI workspaces to represent environments in HCP Terraform, but HCP Terraform workspaces are the primary unit for separate state and runs. Another misconception is that projects are limited or optional metadata; in reality, they are intended to help organize workspaces within an organization. This matches HashiCorp guidance on using projects to group related workspaces and using separate HCP Terraform workspaces for separate environments or infrastructure instances.
- A. Correct.
Correct. In HCP Terraform, projects are intended to organize related workspaces within an organization. Creating a project for each application domain and then placing dev, staging, and prod workspaces inside that project is a practical and recommended way to group related infrastructure for visibility and management.
- B. Incorrect.
Incorrect. This confuses HCP Terraform workspaces with Terraform CLI workspaces. In HCP Terraform, each workspace is typically used as an independent unit of infrastructure and state. Using CLI workspaces to model environments in HCP Terraform is generally not the recommended organizational pattern for separate environments like dev, staging, and prod.
- C. Incorrect.
Incorrect. Projects can contain multiple workspaces, so this statement is factually wrong. While a single project could be used, it would not meet the team's requirement to group related workspaces by domain for easier visibility and separation.
- D. Incorrect.
Incorrect. Organizations are higher-level boundaries in HCP Terraform and are not required just to separate application domains. Projects are specifically used to organize related workspaces, so saying they are only for VCS connections is incorrect.