Map Organizations, Projects and Workspaces to Ownership
The first planning meeting about HCP Terraform usually contains a sentence that sounds settled and is not: "one workspace per environment." It is fine until someone asks who can apply to production. An HCP Terraform workspace holds state, variables, run history, permissions and health settings, and it is the unit a team is granted access to. Confusing it with the CLI feature is the most common way a careful team ships a weak boundary.
A useful analogy is a shared office building. A CLI workspace is a different filename for the project file in the same edit suite: the same keycard still gets you in. An HCP Terraform workspace is a separately booked suite with its own keycard list and sign-in sheet.
The hierarchy has three levels. An organization owns billing, single sign-on, teams, the private registry, policy sets and the audit surface. A project groups workspaces and Stacks so access can be granted once to a business unit; project-scoped permissions are part of the paid editions, so verify your plan. A workspace maps to one root module and contains its configuration source, variables, state and history, credentials and team permissions. One workspace is one change unit: configurations planned and applied independently belong in separate workspaces even when they share a repository.
Put the organization at the company or billing boundary, projects at ownership boundaries that already exist, and workspaces at root modules named for what they manage. network-prod tells a reviewer what a plan will touch; prod-1 does not.
The word "workspace" then splits into two objects. The two share a name and little else.
| Aspect | CLI workspace | HCP Terraform workspace |
|---|---|---|
| What it is | A named state instance inside one working directory and backend | A control-plane container with its own state, variables, run queue and history |
| What is shared | Provider configuration, backend credentials and execution environment across every name in that directory | Nothing by default: each has its own variables, team permissions and health settings |
| Who can reach it | Anyone the backend credential admits; the key that wrote dev usually writes prod too | Only members granted a role on that workspace; remote runs assemble their own environment |
| Where runs execute | On your machine | A disposable worker or an agent pool, from a linked VCS branch or uploaded configuration |
The names need not match. With the CLI integration, one configuration can map to several HCP Terraform workspaces by name or tag. That suits review environments: one configuration, a workspace per pull request, one narrow credential, a destroy at the end.
Figure 1 shows the ownership chain and the contrast that costs teams the most.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
O["Organization
billing · SSO · teams · registry"] --> P["Project
groups workspaces by owner"]
P --> W1["Workspace app-dev
state · variables · history"]
P --> W2["Workspace app-prod
state · variables · history"]
W1 --> R1["Run queue
plan → approval → apply"]
W2 --> R2["Run queue
plan → approval → apply"]
C["CLI workspace prod
one directory, renamed state"] -. "same backend and credential" .-> X["Mistaken isolation
dev keycard opens prod"]
R2 --> AC["Cloud account or subscription
the real blast-radius boundary"]
X --> AC
classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
class O,W1,W2 primary;
class P,R1,R2 secondary;
class AC ok;
class C warn;
class X danger;
A workspace is not a cloud account
Workspace permissions decide who may run Terraform; cloud credentials decide what Terraform can reach. If every workspace authenticates with the same static cloud key, an operator who can queue a run in production can change production, however tidy the project tree looks. Pair workspace permissions with workspace-scoped dynamic credentials, so the dev plan role cannot assume the prod apply role.
Figure 2 contrasts the two meanings of workspace by what actually separates them.
One boundary remains. Workspaces manage one root module; Stacks manage a repeatable set of modules across deployments. For a first adoption, workspaces are the smaller step.
Choose VCS, CLI or API-Driven Runs
There are three run workflows, not three products: three ways to hand the same engine a configuration version, variables and a trigger. HCP Terraform always performs the plan and always applies the plan it produced; the workflow decides where the code came from and who can start it. Behavior here was checked against Terraform CLI 1.17.1, hashicorp/tfe 0.83.0 and agent 1.33.x on 5 November 2026.
VCS-driven runs are the primary mode. Link a workspace to a repository, branch and optionally a subdirectory. A pull request starts a speculative plan and posts it as a commit check; a merge starts a standard plan-and-apply run. Reviewers see the plan where they review code, and nobody needs production credentials locally.
CLI-driven runs are the practitioner mode. A cloud block names the organization and selects workspaces by name or tag; the rest of the workflow stays on your machine.
The plan reads the local configuration but the workspace's variables and credentials, and streams logs and a run URL back to the terminal.
Applies and saved plans have hard limits
Three constraints are easy to miss. terraform apply works only in workspaces not linked to VCS, where the repository is the source of truth. A saved plan (plan -out) needs CLI 1.6.0 or later: planning can bypass the queue, applying needs the workspace unlocked, and HCP Terraform discards the plan if another run changes state first. Showing that remote saved plan as JSON requires workspace admin, because it carries unredacted sensitive values.
API-driven runs are the automation mode. The runs API creates a run against a configuration version, with attributes that select the mode. Use it for an existing pipeline or a non-interactive approval flow.
| Run attribute | What it selects |
|---|---|
is-destroy | Plans and applies the removal of everything the workspace manages |
save-plan | Keeps the plan artifact for a later, separate apply |
plan-only | Produces a plan without continuing to apply |
refresh-only | Reconciles state with remote objects without changing them |
target-addrs | Limits the run to specific resource addresses |
It carries the most risk: a token that can create runs can often auto-apply, so scope and audit it.
Execution mode is separate from run workflow. Remote is the default: disposable Linux workers execute Terraform. Local makes the workspace a remote state backend only; policy enforcement, cost estimation and HCP notifications do not apply. Agent runs the work inside your network. Changing it after a plan completes makes that run fail at apply, so drain and lock the workspace first.
The lifecycle is a queue with gates: pending, plan against a frozen configuration and variable snapshot, policy and cost checks, approval unless auto-apply is on, apply, completion. Each workspace runs one thing at a time. Speculative plans and saved-plan planning may run in parallel because they do not write state; the apply stage always takes the workspace lock.
Figure 3 traces the paths and the branch that matters operationally: the run that stops without changing anything.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
A["Change source
commit · pull request · CLI · API"] --> B{"Trigger"}
B -- "pull request" --> S["Speculative plan
no apply, bypasses queue"]
B -- "terraform plan" --> S
B -- "merge to branch" --> Q["Queued run
workspace lock"]
B -- "terraform apply
non-VCS workspace" --> Q
B -- "runs API" --> Q
Q --> P["Plan against frozen
configuration and variables"]
P --> G{"Policy or cost gate"}
G -- "hard fail" --> F["Run stopped
no infrastructure change"]
G -- "pass or warn" --> V{"Approval required?"}
V -- "auto-apply enabled" --> AP["Apply
state written"]
V -- "reviewer approves" --> AP
V -- "reviewer rejects" --> D["Discarded
plan expires"]
S --> RV["Feedback in PR check
or terminal run URL"]
AP --> OK["Completed
run log and state version kept"]
AP -. "provider error mid-graph" .-> T["Partial apply
investigate before retry"]
classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
class A,Q,P,AP primary;
class B,G,V,S secondary;
class OK,RV ok;
class F,D,T danger;
Destroy is a run mode, not a special command path. The CLI, the API and the UI all feed the same plan-then-approve pipeline: the CLI has a destroy command, the API sets is-destroy, and the UI exposes it under destruction settings. For routine retirement, remove the resource block and let a normal plan propose destruction; reserve destroy mode for a whole environment, with a second approver in production.
A destroy still plans first and still needs approval. The destroy plan is reviewable evidence of what will be removed, and lifecycle guards such as prevent_destroy still apply, so a mistaken destroy fails at plan time.
A hard policy failure is a code or policy bug, not an obstacle to override. It stops before apply. A partial apply is the dangerous one: some objects changed, the run errored, and the next plan may propose to repair them. Read the error and the state before retrying, and never answer a failed apply with wider permissions.
Assign Variables, Variable Sets and Dynamic Credentials
HCP Terraform has two variable species. Environment variables are exported into the run shell and carry provider credentials, TF_LOG and provider settings. Terraform variables are input variables for the configuration.
Scope differs from the CLI: a value can be set for one run, one workspace, a workspace-scoped set, a project-scoped set, or a global set. Add *.auto.tfvars, terraform.tfvars and command-line values and you have more layers than most teams need.
The hosted order is longer than the CLI's. Per the current variables documentation, priority sets come first, then the layers a CLI user already knows.
| Order | Source | Owner / scope |
|---|---|---|
| 1 | Priority sets | global, organization-owned project, organization-owned workspace, project-owned project, project-owned workspace — in that order |
| 2 | Command line | -var and -var-file |
| 3 | Shell environment | TF_VAR_ |
| 4 | Workspace variables | the workspace itself |
| 5 | Workspace-scoped set | project-owned |
| 6 | Project-scoped set | project-owned |
| 7 | Workspace-scoped set | organization-owned |
| 8 | Project-scoped set | organization-owned |
| 9 | Global set | organization-owned |
| 10 | Auto-loaded files | *.auto.tfvars |
| 11 | Default file | terraform.tfvars |
Two details break intuition. When two non-priority sets at the same scope conflict, the lexical order of set names decides, not which was edited last: A_Variable_Set beats B_Variable_Set even if B was updated minutes ago. And a priority set forces a value into the run but cannot force the configuration to use the variable; someone can replace the reference with a hard-coded value. Policy checks and run tasks are the enforcement tool.
Give each key one owner. Use project sets for shared values such as a region, workspace-specific variables for genuine differences, and priority sets sparingly for guardrails. Name sets so the lexical tie-break matches intent; if two same-scope sets can define instance_count, rename until only one can.
Sensitive is not write-only
Marking a variable sensitive hides it after saving and redacts it where Terraform knows to redact, but the run can still read it. It does not sanitize state, plan files, provider logs or an output that prints it: sensitive means handled carefully, not write-only. Newer Terraform versions add write-only arguments and ephemeral resources that reduce persistence; check your pinned CLI and provider.
Dynamic provider credentials are the better answer for cloud access. Instead of storing a long-lived key, configure a trust relationship. At the start of each plan or apply, HCP Terraform issues a short-lived OpenID Connect workload identity token with claims about the organization, workspace and run phase. The cloud verifies it against HCP Terraform's public key and returns temporary credentials, which are placed in the run environment and discarded when the run ends. The workspace holds variables such as TFC_AWS_PLAN_ROLE_ARN and TFC_AWS_APPLY_ROLE_ARN, not a secret. Agents must be 1.7.0 or newer.
The leverage is in the trust policy: give the plan role read-only actions, the apply role only the resources that workspace owns, and key the condition on workspace name and, where supported, run phase. A compromised plan then cannot delete anything, and a dev workspace cannot assume the prod role.
A composite scenario shows why. A forty-person platform team starts with one global set holding an AWS access key, because it makes every workspace work. Months later a contractor on payments-dev copies the key into a local script, and it reaches production because the trust boundary was never expressed. The fix is two roles, a workspace-scoped trust policy, a plan/apply split, and deletion of the global key.
Use Private Registries and Agent Execution Where Needed
A private registry solves a distribution problem. Once a module serves more than one team, pointing every root at a Git ref means consumers track an unreviewed branch and breakage arrives without a version number. HCP Terraform's private registry hosts modules and providers for one organization, uses your VCS repository as the source of truth, and turns Git tags into versions. Consumers write a normal registry source and constraint:
The registry gives reviewers a place to read inputs, outputs and examples, and gives policy something stable to point at. A rule can require non-root modules to come from the registry and to use recent versions, which is hard to express against arbitrary Git URLs. Public modules can be synchronized in, so the organization curates a recommended set.
Two caveats. The registry is organization-scoped, so a module in one organization is not automatically visible in another, and a CLI user must authenticate to the right hostname. And a private module is still code with your privileges: publishing it is not reviewing it.
Agents solve a different problem: reaching infrastructure the public internet cannot reach. An agent pool is a group of lightweight workers inside a private network. Each agent makes outbound connections to HCP Terraform and polls for work, so you open no inbound rule. A workspace in agent mode sends runs to a pool, and any available agent can take the plan or apply, so never depend on local disk state between phases. Pools can be scoped to projects, workspaces and Stacks.
The trust question moves rather than disappears. The agent host becomes part of your trusted computing base: it holds the pool token, receives variable values, and runs Terraform with the workspace's cloud identity. Patch it, isolate it, restrict who can replace it, and revoke pool tokens only after in-flight runs finish. Agent hooks run custom programs with access to the run environment, so a hook is production code. Idle, busy and unknown agents count against capacity; an unknown agent that does not report within five minutes becomes errored.
Agent execution is not data residency
The control plane stays hosted. Agent execution keeps calls to private endpoints local, but state, variables, run metadata and logs still live in HCP Terraform. If the requirement is that no production data leaves the region, an agent alone does not satisfy it; choose the region or HCP Europe and confirm the data terms.
Not every team needs agents. If providers talk to public cloud APIs, remote execution is less to operate. Add agents when a private network, an on-premises provider or a regulatory constraint makes remote execution impossible.
Read Run History, Health Assessments and Cost Signals
Run history replaces a pile of CI logs and a Slack archaeology channel. Each run records who queued it, the configuration version and commit, the variable snapshot, plan, policy and cost results, approvals, the apply log, and the resulting state version. That answers the incident questions: what changed, who approved it, which variables were in effect, and what the plan said. Treat logs as audit records; a configuration that prints a token has printed it into retained evidence.
Health assessments are the continuous half. HCP Terraform's health assessments combine drift detection with continuous validation. Drift detection asks whether the real object still matches configuration; continuous validation evaluates check blocks, preconditions and postconditions. An assessment runs as a speculative plan, so it writes nothing and does not consume run concurrency, though an errored latest run postpones it.
The requirements are specific. Drift detection needs Terraform 0.15.4 or later; drift plus continuous validation needs 1.3.0 or later. The workspace needs remote or agent execution, one successful apply, and a latest run that is not errored, canceled or discarded. The documentation lists health assessments as Standard and Premium: record that entitlement before promising a drift dashboard.
Drift detection is not state drift. Configuration drift means the remote object contradicts the configuration; state drift means it changed without invalidating it, and refresh-only is the tool for that. Resolution is a decision: queue a normal plan and overwrite the drift, or change the configuration to adopt reality. Never auto-apply a drift finding; a human must choose.
Continuous validation is strongest when assertions are few and pointed at things that break: an endpoint's status code, a certificate near expiry, an image channel ahead of the deployment. The documented false-positive trap is a data source that resolves a newer value during the assessment than during the last apply. Nested data sources that read the deployed object keep it honest.
Notifications close the loop only if they have an owner. HCP Terraform sends per-workspace notifications to Slack or any webhook, including run events and health results. Route production drift to the owning team and failed applies to whoever is on call; do not send every speculative plan to a shared channel, because a firehose trains people to ignore the message that matters. A notification is not a pager, and a dashboard is not a remediation plan. Figure 4 shows the loop and its pause condition.
Cost estimation is a signal, not a budget. It is disabled by default at the organization level, supports AWS, GCP and Azure resources, and appears between plan and apply. It is suppressed for targeted runs, because a targeted plan would understate the total. The estimate reflects list-price resource costs, not data transfer, usage charges, support, tax or commitments. Use it to catch the accidental m5.24xlarge, not to reconcile the invoice.
The bill is a different number. HCP Terraform prices paid plans per managed resource per hour: a resource in workspace or Stack state with mode = "managed", counted at the peak for each hour.
Not everything counts. Data sources, null_resource and terraform_data are excluded. The free plan is capped at 500 managed resources, and tiers differ sharply in concurrency. A workspace that is cheap in cloud spend can still exhaust a concurrency limit during an incident.
Verify Plan Entitlements and Data Requirements Before Adoption
Record the entitlement, not the marketing page
Everything above assumes a feature exists in your organization. HCP Terraform documents free, Essentials, Standard and Premium plans, with tier-dependent caps, concurrency and gates, and the public plan structure has changed more than once. Feature pages add their own gates and do not always agree with the summary matrix: health assessments are documented as Standard and Premium, cost estimation as unavailable on free and Essentials, policy enforcement as a free-tier capability in one place and as unavailable below Standard in another. Do not guess. Open the feature page, the plan matrix and the pricing page on the same day, and record what each said.
Date-stamp the record. "Drift detection is included" has a shelf life measured in releases and repricing. Record the verification date, URL, hostname, region, plan name and exact wording. Six months later, "the docs said so" is not the same answer as "here is the page we read on 5 November 2026".
Data requirements split into four questions:
- State: lives in your organization's HCP Terraform region, contains resource attributes and often secrets, and stays remote even when runs are local.
- Variables and credentials: stored and injected by HCP Terraform. Dynamic credentials avoid a stored cloud key, and agents do not move the control plane into your network.
- Logs and history: run logs, plan output, comments and state versions are retained per the product and your settings. Assume an audit or legal hold can reach them.
- Region: if you use HCP Europe, confirm the hostname and contract terms instead of assuming the default
app.terraform.ioorganization is European.
Then check the constraints a proof of concept hides: the free plan's 500-resource cap, concurrency, agent capacity, retention and export, downgrade behavior (features can become read-only while data is retained but inaccessible), and notice periods. The free plan is an evaluation path, not a capacity plan.
Design a hosted workspace
Status: design-only by default. Required steps use no cloud credentials and provision nothing. The optional run uses a disposable organization and a local-only configuration, never production.
Prerequisites. Terraform CLI 1.17.1, a text editor, an HCP Terraform organization you may use for evaluation, and, for the optional run, a throwaway repository and a budget you can lose.
Setup. Create labs/p27/ with four documents and an evidence/ folder, and use placeholders for identifiers.
| Deliverable | What to record | Pass condition |
|---|---|---|
ownership.md | One product's hierarchy: organization; projects platform and application; workspaces network-dev, network-prod, app-dev, app-prod — with owner, root module, change cadence and cloud identity per workspace | No two environments share a credential by accident |
ownership.md | Execution mode per workspace in one sentence: remote for a public provider, agent for a private endpoint, local for a legacy pipeline | Each choice names what it gives up |
variables.md | One owner and one scope per key, sensitive values marked, dynamic credential variables and the trust condition limiting each role to its workspace | No two same-scope sets can define the same key |
runs.md | Which events produce a speculative plan, who approves app-prod, whether auto-apply is allowed, how a destroy is requested and who is second approver | Policy failure and partial apply each have a stated response |
eligibility.md | Date, hostname, region, plan, managed-resource count, concurrency, and the status of health assessments, cost estimation, policy, agents, audit logging and registry limits | Every claim cites a URL and an exact sentence; disagreements with the plan matrix are flagged |
Optional sandbox run. Create the project and app-dev, connect the throwaway repository, and confirm execution mode and variables. Put this in main.tf:
terraform {
cloud {
organization = "example-eval-org"
workspaces {
name = "app-dev"
}
}
}
Run terraform init, then terraform plan; confirm a speculative plan and URL. Merge a comment-only change and watch the queued run; it should report no changes. Do not approve a run that proposes infrastructure changes.
Failure check. On paper, give both app workspaces the same apply role, or let two same-scope sets define region. Explain what the run would reach or which value wins, restore the design, and record the near miss.
Pass criteria. One credential per environment, one owner per key with no lexical surprise, a named production approver, and a dated eligibility record citing a page per claim. Fail if a workspace name is the only dev/prod separation, a global set holds a long-lived cloud key, a sensitive variable is assumed unreadable, or a feature is claimed without a dated source.
Cost and cleanup. Design-only: zero. The optional organization may charge for managed resources if you apply; keep the configuration local or provider-free, destroy sandbox resources, and delete the workspace and project after capturing evidence. The 500-resource cap is a limit, not a cleanup strategy.
Evidence to keep. The four files, the dated eligibility table with URLs, a sanitized export of the plan and run history, and a note on the assumption you broke.
Next in the Series
In Policy as Code and Cost Governance for Infrastructure Teams, we'll explore Enforce concrete organization rules with the policy framework and execution model that actually support them.