Domain 8 of 8 · Chapter 1 of 4

Use HCP Terraform to Create Infrastructure

Where a run executes: remote, agent, and local modes

A workspace's execution mode answers one question: where does Terraform actually run? You choose it once per workspace, and it decides whether plan and apply happen on HashiCorp's infrastructure, on a machine you control inside a private network, or on your own laptop. State is a separate matter: it is always stored remotely in the workspace, so the choice is about execution, not storage. From here you will see how each execution mode runs the same plan and apply you already use from the CLI, how a run then moves through its ordered stages to an apply, and how VCS, CLI, and API workflows trigger runs, so you can place a workspace in the right mode and predict what any run will do. The figure groups the three modes by where their run executes and shows the one thing they all share.

Remote mode, the default

In Remote execution mode HCP Terraform performs Terraform runs on its own disposable virtual machines[1], giving every run a consistent managed environment. That managed environment is what makes the run's extra features possible: policy enforcement, cost estimation, and notifications all attach to a remote run. Remote is the default for a new workspace, and it is the mode most of this page assumes.

Agent mode, for private and on-prem infrastructure

Remote mode's shared VMs can only reach infrastructure that is exposed to them over the network, so a target inside an isolated or on-premises network needs a different mode. HCP Terraform agents let you manage isolated, private, or on-premises infrastructure while keeping your network secure[2]: you install a lightweight, self-hosted agent inside the network, and the agent requires only outbound connectivity to HCP Terraform[2], polling it for work and executing runs locally. Agent mode is a paid capability; your HCP Terraform plan determines the number of agents you can use[2].

Local mode, a state backend only

Local execution mode makes the workspace act only as a remote backend for Terraform state, with all execution occurring on your own workstations or continuous integration workers[1]. Because the run no longer happens on HCP Terraform, everything that rides on a managed run goes away: no remote runs, no policy checks, no cost estimation. The predictable misread is that Local mode also keeps state on your disk. It does not. State still lives in the workspace remotely, and only the run moves to your machine.

Remote (default)AgentLocalHCP Terraform VMsSelf-hosted agentin your private networkYour workstation or CIState is stored in the HCP Terraform workspace, in every mode
Execution mode sets where a run executes: HCP Terraform VMs, a self-hosted agent, or your own machine. State stays in the workspace in all three.

The run lifecycle: from queue to apply

Every apply-capable run follows the same ordered path, and knowing that order is most of what this objective asks. A run is created in the Pending state, and HCP Terraform processes each workspace's runs in the order they were queued[3], holding a run Pending until every run ahead of it finishes. So each workspace applies one run at a time, in queue order, and editing a variable or the configuration while a run is mid-flight only affects the next run, not the one already planned.

The stages, in order

Once it leaves the queue, the run moves through plan, then cost estimation, then policy check, then apply. Cost estimation appears in the run as an extra phase between the plan and apply[4], and it runs before the policy check. That ordering is the whole point: because the estimate is ready first, a Sentinel policy can read the monthly cost delta the run would introduce[4] and block a change that would spend too much. Cost estimation is enabled per organization and supports the AWS, GCP, and Azure providers[4], reporting a total monthly cost alongside that delta. Reading the order as policy-check-then-cost, or as one combined step, is the classic trap; cost estimation always comes first.

Manual apply versus auto-apply

When the plan and its checks succeed, a run does not apply itself by default. It pauses in a Needs Confirmation state until a user with permission to apply runs takes action[3], clicking Confirm & Apply to proceed or discarding the run. Enabling auto-apply on the workspace removes that pause, so a plan that finishes without error applies automatically. The figure traces the full path from the queue to apply and marks the Needs Confirmation gate that manual apply adds.

Pendingin the run queuePlanpreview changesCost estimationcost + deltaPolicy checkSentinel gateNeeds Confirmationmanual apply pausesApplyauto-apply skips gate
A run's ordered stages: Pending, Plan, Cost estimation, Policy check, Apply. Manual apply pauses at a Needs Confirmation gate; auto-apply skips it.

Starting runs: VCS, CLI, and API workflows

A run has to be triggered, and HCP Terraform offers three workflows to do it. They differ in what starts the run, not in how the run then executes, and the figure maps each trigger to the kind of run it produces: a full run that can apply, or a speculative plan that cannot.

VCS-driven

HCP Terraform registers webhooks with your VCS provider and automatically queues a Terraform run whenever new commits are merged to that branch of the workspace's linked repository[5]. A pull request is handled differently: HCP Terraform performs a speculative plan when a pull request is opened against that branch and posts a link to the plan in the pull request[5]. A speculative plan is a plan-only preview that can never apply, defined in full below. So a commit or merge produces a full run, while a pull request produces a speculative plan whose result reviewers read in the PR.

CLI-driven

With the cloud block configured, you keep using the Terraform CLI locally while the run executes in HCP Terraform. The two commands split by run type: a terraform apply starts a full run in the workspace, while terraform plan starts a speculative plan using configuration files from your local directory[6], which lets you check results, including Sentinel policy compliance, without copying sensitive variables to your machine.

API-driven

The API-driven workflow uploads a configuration version through the Runs API and is the most flexible, at the cost that it requires you to create some tooling[7] to package and send the configuration. It suits systems that generate configuration or orchestrate runs outside a version-control repository.

Speculative plans

A speculative plan is a plan-only run: it shows possible changes, and the policies affected by those changes, but cannot apply any changes[1]. Because it never touches real infrastructure, it can begin without waiting for other runs to finish[1] and does not take the workspace lock. There is no Confirm & Apply on a speculative plan. To actually change infrastructure you trigger a full run, from a commit, a terraform apply, or an apply-capable API run.

Commit or merge (VCS)terraform apply (CLI)Apply run (API)Pull request (VCS)terraform plan (CLI)Plan-only run (API)Full runcan apply; takes the workspace lockSpeculative planplan-only; never applies; no lock
Each trigger yields a full run (commit, terraform apply, API apply) or a speculative plan (pull request, terraform plan, plan-only API run).

Exam-pattern recognition

TA-004 items on HCP Terraform are mechanical: they test whether you can place a run in the right execution mode, name its stages in order, and tell a full run from a speculative one. No cloud-provider-specific knowledge is required.

An execution-mode stem describes where runs should happen. Map the intent: a consistent managed environment with policy and cost checks is Remote (the default); infrastructure in an isolated or on-premises network is Agent mode; and using the workspace only to hold state while Terraform runs on your own machine is Local mode. The planted error is that Local mode also stores state locally. It does not, because state stays in the workspace remotely in every mode, and only the run location changes.

A lifecycle stem asks for the stage order or where one stage sits. The order is plan, then cost estimation, then policy check, then apply. The favorite trap puts the policy check before cost estimation or merges them; hold the line that cost estimation runs first, which is exactly what lets a Sentinel policy gate on the estimated cost. A companion trap claims a plan applies automatically. By default it does not: a finished plan waits in Needs Confirmation for a Confirm & Apply, unless the workspace has auto-apply enabled.

A queue stem describes two runs or a variable change during a run. Each workspace processes runs one at a time in queue order, and a change made mid-run affects only the next run, not the one already planned.

A workflow stem gives a trigger and asks what happens. A commit or merge to the tracked branch starts a full run that can apply; opening a pull request starts a speculative plan whose result is posted back to the PR. The recurring trap is that a speculative plan can be confirmed into an apply. It cannot: a speculative plan is strictly plan-only, has no Confirm & Apply, takes no workspace lock, and never modifies state.

Execution modes: where the run and state live

BehaviorRemote (default)AgentLocal
Where plan and apply runHCP Terraform VMsSelf-hosted agent in your networkYour workstation or CI
Where state is storedHCP Terraform workspaceHCP Terraform workspaceHCP Terraform workspace
Reaches private or on-prem infraNo, needs a reachable APIYes, from inside the networkYes, runs where you run
Policy checks and cost estimationYesYesNo, disabled
Typical useDefault managed runsIsolated or private networksRemote state backend only

Decision tree

Reach private or on-prem infra?Only store state, run yourself?Want a managed run environment?Agent modeself-hosted agent, private netLocal modestate backend onlyRemote (default)runs on HCP Terraform VMsRemote (default)the default modeAlways: state is stored remotely in the workspaceYesYesYesNoNoNo

Sharp facts the exam loves — give these one last read before exam day.

Cheat sheet

Sharp facts the exam loves — scan these before test day.

Remote execution runs Terraform on HCP Terraform VMs

In a workspace using Remote execution mode (the default), HCP Terraform (formerly Terraform Cloud) performs plan and apply on its own disposable virtual machines using that workspace's configuration, variables, and state. Switching a workspace to Local execution mode makes it act only as a remote state backend while runs execute on your own workstation or CI, which disables policy checks, cost estimation, and remote runs.

Trap Assuming Local execution mode also stores state locally — it still stores state remotely; only the run execution moves to your machine.

5 questions test this
Agent execution mode reaches private infrastructure

Agent execution mode runs Terraform on self-hosted HCP Terraform agents installed inside a private network, letting HCP Terraform manage runs against isolated or on-premises infrastructure it cannot reach directly.

State is stored remotely per workspace

HCP Terraform stores Terraform state remotely and separately for each workspace, automatically retaining prior state versions. When you use the cloud integration you do not add a separate backend block, and state is never committed to version control.

Trap Thinking you still need a backend block alongside the cloud integration — the cloud block replaces backend configuration and manages state itself.

10 questions test this
Remote run stage order

A remote run moves through ordered stages: it queues (pending), executes a plan, then runs cost estimation, then any policy check, and finally performs the apply (plan -> cost estimation -> policy check -> apply). HCP Terraform surfaces the output of both the plan and apply phases on the run's details page.

Trap Thinking the policy check precedes cost estimation, or that they are one combined step; cost estimation always runs first (plan -> cost estimation -> policy check -> apply), which is why a Sentinel policy can gate on the cost estimate.

6 questions test this
Manual apply pauses for Confirm & Apply

With manual apply (the default), a finished plan pauses and a user with apply permission must click Confirm & Apply to proceed or Discard the run. Auto-apply, when enabled on the workspace, automatically applies plans that complete without errors.

Trap Assuming auto-apply is the default — HCP Terraform requires manual confirmation unless auto-apply is explicitly turned on.

5 questions test this
Each workspace processes its run queue in order

Every workspace maintains its own run queue and processes apply-capable runs one at a time, in order. Changing variables or configuration only affects future runs, not a run that has already been planned.

HCP Terraform cost estimation run stage

In an HCP Terraform run, cost estimation is a distinct stage that runs after the plan and BEFORE the policy check (order: plan -> cost estimation -> policy check -> apply), which is why a Sentinel policy can reference the estimate via the tfrun import. It produces the estimated total monthly cost of the resources in the plan plus the monthly delta (the cost change from the proposed run) for supported major providers (AWS, Azure, GCP), and is enabled per-organization in the organization settings.

Trap Assuming cost estimation runs after, or together with, the policy check; it actually runs before the policy check, which is exactly what lets a Sentinel policy gate on the estimated cost.

6 questions test this
Three run workflows: UI/VCS, CLI, and API driven

HCP Terraform can start runs three ways: UI/VCS-driven (webhooks from a connected repository), CLI-driven (running terraform plan/apply locally with the cloud block configured), and API-driven (uploading a configuration version through the Runs API).

6 questions test this
Speculative plans preview but cannot apply

A speculative plan is a plan-only run that previews proposed changes and policy results but can never apply changes or modify state. Because it cannot alter infrastructure, it bypasses the workspace lock and does not block other runs.

Trap Believing a speculative plan can be confirmed into an apply — it is strictly read-only and has no Confirm & Apply.

9 questions test this
Commit triggers a full run, PR triggers a speculative plan

For a VCS-connected workspace, a commit or merge to the tracked branch triggers a full run (plan then apply), while opening a pull request triggers only a speculative plan whose result is posted back to the PR.

4 questions test this

References

  1. HCP Terraform: remote operations and execution modes
  2. HCP Terraform agents
  3. HCP Terraform run states and stages
  4. HCP Terraform cost estimation
  5. UI/VCS-driven runs in HCP Terraform
  6. CLI-driven runs in HCP Terraform
  7. API-driven runs in HCP Terraform