HCP projects, variables and collaboration
Organize workspaces around ownership
An organization groups HCP Terraform resources and users; a project groups related workspaces and can provide a permission boundary where the selected edition supports project-scoped permissions. A workspace contains its own state and run context. Choose separate workspaces when components have different lifecycles, access requirements or failure domains. A project name or a workspace name does not itself enforce cloud IAM isolation.
Organization: meadow-labs (fictional) Project: storefront Workspace: catalog-dev Workspace: catalog-prod Project: shared-services Workspace: network-prodThe catalog development and production workspaces can use the same reviewed module but should have separate state and appropriate credentials. Moving a workspace between projects may change access, so review inherited permissions and variable sets before a move.
Design an access matrix
Use a fictional team with distinct operational needs. The matrix below is a design intention, not a claim about exact predefined HCP roles. Map it to the currently available permission controls before implementing it.
Team Dev plan Prod plan Prod apply State accessCatalog authors yes no no only as neededRelease reviewers yes yes no only as neededRelease operators yes yes yes only as neededAuditors read read no separately approvedRestrict who can alter variable sets, connect VCS, manage tokens or change execution mode as well as who can apply. Plan permission is not harmless: plans and logs may reveal configuration or sensitive information. Review effective permissions from team membership and project inheritance. Keep production credentials scoped to production workloads.
Separate Terraform variables from process environment
A Terraform variable supplies an input declared in the root module. An environment variable supplies a value to the process and may configure a provider or tool. HCP Terraform can store workspace variables and reusable variable sets. An HCL value can represent a collection when configured as HCL; a plain string is not automatically a list. For the fictional catalog use non-secret values only.
Terraform input: environment = "dev"Terraform input: replicas = 2 (HCL number)Environment variable: TF_LOG = WARN (illustrative)A sensitive designation helps hide a value in normal displays but does not guarantee its exclusion from state, saved plans or logs. Prefer short-lived workload identity where available; do not copy credentials into examples. Local execution does not evaluate hosted variable sets.
Resolve variable collisions using scope and priority
The platform has its own precedence rules, which are distinct from the ordinary local CLI ordering. A priority global set can take precedence over a workspace value with the same key. Non-priority workspace-specific values generally override non-priority sets at broader scopes, subject to the full documented order, including CLI-supplied values and conflicts among sets. This example restricts the comparison to a single key, one set and one workspace variable, with no other input sources.
Case A: non-priority global set environment = "test" workspace environment = "dev" Expected effective value: devCase B: priority global set environment = "test" workspace environment = "dev" Expected effective value: testPriority does not mean secret or secure. It changes precedence, not authorization. Avoid accidental collisions, document why a priority set exists and inspect the effective input source before planning. Equal-scope collisions have further ordering rules; consult the current precedence reference instead of guessing based on creation time.
Share modules without sharing every state file
A private registry enables organization-wide discovery and reuse of versioned modules or providers. It does not automatically grant access to workspace state. Select a reviewed module version, review its dependency and upgrade policy, and restrict publishing rights. Treat private dependencies as executable supply-chain inputs. State sharing is an independent choice. A consumer that reads remote state outputs may require permission to the underlying state snapshot, so prefer a narrower output-sharing interface where appropriate. Never make a real state snapshot public to simplify integration.
Review service edition and operational boundaries
Feature availability, billing model, project permission controls, agent capacity and regional differences must be checked against the current subscription documentation for the specific organization. No prices, quotas or free-tier entitlement are assumed in this course. The offline exercise uses no account. HCP Terraform is managed by the vendor; teams still own configuration, authorization, cloud costs, review, recovery plans and workload health. Self-managed Terraform Enterprise introduces additional operational duties covered in the next chapter.
Practice and next step
Use the project access worksheet to identify excessive privilege and predict the two variable outcomes. Explain why separate states do not guarantee separate credentials. Reference: terraform-concept-hcp-projects-variables-and-collaboration. Official documentation: https://developer.hashicorp.com/terraform/cloud-docs/projects, https://developer.hashicorp.com/terraform/cloud-docs/variables and https://developer.hashicorp.com/terraform/cloud-docs/overview.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HCP projects, variables and collaboration — knowledge check
Review hosted run and collaboration decisions.
What is an appropriate reason for separate dev and production workspaces?
In the restricted example, what overrides a workspace variable?
Does local execution evaluate hosted workspace variable sets?
What does a private registry provide?
What should a team verify before moving a workspace to another project?