Skip to main content
This article explains where your Terraform runs execute when using HCP Terraform, and what each execution mode means for collaboration, available features, and variable handling. Understanding execution modes helps teams choose the right balance of security, reachability, and HCP feature access.

Execution modes — at a glance

HCP Terraform supports three execution modes. Execution mode is configured per workspace (not per organization or project), so different workspaces can use different modes:
  • Remote (default)
  • Local
  • Agent (self-hosted)
Below we describe each mode, the trade-offs, and common gotchas.

Remote (default)

When a workspace is set to remote execution, Terraform plan and apply operations run on HashiCorp-managed infrastructure. HCP provisions ephemeral VMs/workers for each run and tears them down when finished. Benefits
  • Team collaboration and visibility: runs, plans, and who triggered them are visible in the HCP UI.
  • Full feature access: remote execution enables features such as policy enforcement, cost estimation, notifications, run logs, and detailed run output.
  • Secure, managed environment: HCP handles ephemeral worker provisioning, isolation, and maintenance.
State behavior
  • Terraform state is stored remotely in the workspace. HCP manages locking, versioning, and encryption for the remote state.
When to use remote
  • Recommended for most teams that want the full HCP feature set and consistent, auditable runs.
Use remote execution to get full policy and collaboration features and to avoid maintaining your own execution hosts.

Local

In local execution mode, plan and apply operations run on the machine that invokes the Terraform CLI — for example, a developer laptop or a CI runner. HCP still stores and coordinates the workspace state but does not execute the runs. Typical usage
  • Developers who want to run Terraform locally while retaining remote state, locking, and state history in HCP.
State behavior
  • The workspace state remains in HCP (remote state), so you still get locking, encryption, and version history. The actual plan/apply executes locally.
Example local CLI usage
Important variable behavior (common gotcha)
  • Workspace variables and variable sets configured in the HCP UI are NOT injected into local CLI runs. When you run locally, Terraform reads variables from:
    • Command-line flags: -var 'key=value' or -var-file=secrets.tfvars
    • Local .tfvars files
    • Environment variables: TF_VAR_<NAME>
Example ways to pass variables locally
Workspace variables and variable sets in HCP are not applied to local execution runs. Provide required values via -var, -var-file, or TF_VAR_* when running locally.

Agent (self-hosted agent)

Agent mode is designed for scenarios where HCP cannot directly reach the infrastructure that Terraform must manage — for example, private networks, on-premises systems, or environments behind firewalls. With agent mode you run a lightweight, self-hosted agent inside your network. How it works
  • The agent establishes an outbound connection to HCP. The HCP control plane sends run requests to the agent over that connection.
  • Plan and apply operations execute on the self-hosted agent, enabling the agent to reach resources that HCP-managed workers cannot.
  • The same agent model can support both HCP Terraform and Terraform Enterprise, allowing consistent execution behavior across products.
Use cases
  • Managing resources in private datacenters or networks without inbound access.
  • Environments that require execution to remain on customer-controlled infrastructure.
  • Workflows that need agents to access internal APIs, VMWare, private clouds, or isolated Kubernetes clusters.
Security and networking
  • Agents communicate outbound to HCP, which simplifies firewall rules (no inbound required).
  • You are responsible for securing and maintaining the agent hosts according to your organization’s policies.
State behavior
  • As with other modes, workspace state is stored remotely in HCP. The agent performs the execution but relies on HCP for state coordination, locking, and history.

Execution modes comparison

Putting it all together — practical examples

  • Networking or application workspace that benefits from HCP features: use remote execution to leverage policy enforcement, cost estimation, and run visibility.
  • Monitoring or infrastructure that must reach private resources: use agent mode to keep execution inside the private network while using HCP for state coordination.
  • A database or operations team that prefers to run applies from laptops: use local execution but ensure CLI receives necessary variables via -var, -var-file, or TF_VAR_*.
Key takeaway
  • Execution mode is configured per workspace. Choose the mode that matches access constraints, security requirements, and desired HCP features for each workspace.
For more detail on agent installation and advanced configuration, consult the official HCP / HashiCorp documentation.

Watch Video