HCP Terraform
This domain covers the hosted and enterprise-grade features that HashiCorp builds on top of core Terraform: collaborative workspaces, remote execution, version-control integration, policy enforcement, cost controls, and module sharing. HashiCorp does not publish objective weightings for Terraform Associate 004, so this is one of the estimated-even-weight topic areas under the current blueprint rather than a confirmed 6%; treat any question-count figure as unverified. Questions test whether you can distinguish HCP Terraform concepts from CLI-only behavior, identify correct tier requirements, and reason through workflow steps in sequence.
HCP Terraform Workspaces vs CLI Workspaces
Core Distinction
| Dimension | CLI Workspaces | HCP Terraform Workspaces |
|---|---|---|
| Scope | Directory-local state isolation | Full unit of collaboration with its own variables, permissions, and runs |
| State storage | Local backend (or configured remote backend) | Managed remotely by HCP Terraform automatically |
| Purpose | Separate environments within one config | Separate configs, teams, permissions, and histories |
| Switching | terraform workspace select <name> | Switch via UI, API, or terraform init with different workspace config |
| Variables | Shared terraform.tfvars or -var flags | Per-workspace variable sets, stored securely in HCP Terraform |
| Access control | None — filesystem-level only | Role-based: owners, admins, write, plan, read |
CLI workspaces live inside a single backend configuration and share the same Terraform configuration files. They only isolate state. HCP Terraform workspaces are independent units: each has its own state file, variable values, run history, VCS connection, team access, and notification settings.
What "Remote Backend" Means Here
When you configure backend "remote" (or the newer cloud block) in terraform.tf, CLI runs are forwarded to HCP Terraform. The workspace name in the cloud block must match an existing HCP Terraform workspace. Operations appear as runs in the HCP Terraform UI.
terraform {
cloud {
organization = "my-org"
workspaces {
name = "production-vpc"
}
}
}
Common Traps
- The exam frequently presents CLI workspaces as a substitute for HCP Terraform workspaces — they are not equivalent; CLI workspaces do not provide team access or run history.
- A HCP Terraform workspace using the
cloudblock does not supportterraform workspace selectto switch between HCP Terraform workspaces from the CLI. - The
workspaces { tags = [...] }option in thecloudblock allows a single CLI configuration to target multiple HCP Terraform workspaces by tag, but you must stillterraform workspace selectamong them locally.
Remote Execution: Runs, Plans, Applies
Remote execution means HCP Terraform's worker agents perform plan and apply operations in a managed, isolated environment — not on the operator's local machine.
Run Lifecycle
How an HCP Terraform run progresses from trigger to completion.
Run Types
| Run Type | Triggered By | Default Behavior |
|---|---|---|
| Plan only | PR/MR opened against VCS branch | Produces speculative plan, never applies |
| Normal run | Merge to tracked branch, API, UI | Plan → policy check → apply |
| Destroy run | UI toggle or TF_DESTROY=true via API | Plans a destroy, then applies |
| Refresh-only | UI or API with refresh-only flag | Updates state without changing real infrastructure |
Execution Modes
| Mode | Where Code Runs | When to Use |
|---|---|---|
| Remote | HCP Terraform managed workers | Default; code and secrets stay in HCP Terraform |
| Local | Operator's machine; state stored in HCP Terraform | Legacy setups; avoids agent egress limits |
| Agent | Self-hosted HCP Terraform Agent in private network | Resources unreachable from HCP Terraform's SaaS workers |
HCP Terraform Agents are required (and are a paid HCP Terraform capability, not part of the free offering, or available via Terraform Enterprise) when your infrastructure resides on private networks without internet access.
Auto-Apply
When auto-apply is enabled on a workspace, confirmed plans apply immediately without human approval. When disabled (default), an operator must confirm in the UI or via API. Auto-apply is set per workspace.
Common Traps
- A speculative plan (from a PR) cannot be applied — it is read-only and for review only.
- Disabling auto-apply does not skip policy checks; policy checks always run between plan and apply.
- Remote execution mode is the default for new workspaces; local mode must be explicitly selected.
- Agents run outside HCP Terraform infrastructure — the agent polls HCP Terraform for jobs; HCP Terraform does not push to the agent.
Worked Scenario
Requirement: Your team's AWS infrastructure is in a VPC with no internet gateway. HCP Terraform's SaaS runners cannot reach it. What execution mode do you choose?
Reasoning: Remote execution mode uses HashiCorp-managed workers that must reach your endpoints over the internet. Local mode stores state in HCP Terraform but runs locally — feasible but not automated. Agent mode with a self-hosted agent deployed inside the private VPC is the correct answer; the agent initiates outbound connections to HCP Terraform, so no inbound connectivity is needed.
Unlock with a paid plan
9 more sections (about 2,448 words) continue below. Every paid plan unlocks all 004 study guides, the full question bank and mock exams, from $4.97/month.