skip to content

In HCP Terraform, what do the Remote, Local and Agent execution modes change about where a run executes, and what does Local give up?

level: middleimportance: should knowfreq 46%

answer

  1. a per-workspace setting with inheritance
  2. disposable VMs or your own machines
  3. something polling from inside the network
  4. state stays while features go
  5. the Variables page disappears

basics

~20 s

Remote runs on HCP Terraform's disposable VMs. Agent runs on agents you host, still managed by HCP Terraform. Local runs on your own machines with HCP Terraform storing only state, giving up workspace variables, policy enforcement, cost estimation and notifications.

solid answer

~40 s

Execution mode decides where Terraform runs for a workspace. **Remote** uses HCP Terraform's disposable VMs and enables features such as Sentinel enforcement, cost estimation, notifications and version control integration. **Agent** keeps runs managed by the service but executes them on agents you host, which poll HCP Terraform, so private infrastructure needs no public ingress; agents are a paid feature. **Local** runs on your workstations or CI workers, and the workspace acts only as state storage. Local gives up those run features, and HCP Terraform does not evaluate workspace variables or variable sets, so credentials and values must already exist wherever you run. Users also need read and write state plus lock and unlock permissions. A new workspace defaults to Project Default, inheriting its project's mode.

go deeper

for a junior

Recall the three names and one fact for each: Remote uses HCP Terraform's VMs, Agent uses machines you host, and Local uses your own workstation while the service keeps only the state.

for a middle

Explain what follows from each location: where variables come from, why agents need no public ingress, which features Local loses, and how Project Default makes a workspace inherit its mode.

for a senior

Show operational care: the planned run that errors after a mode change, the documented lock-change-unlock sequence, the extra state and lock permissions Local demands, and organization-default changes discarding operations in progress.

for a principal

Frame the mode as a standing default per project. Local weakens the central controls you probably bought the service for, while agents add a fleet to own, so decide who can override and why.

## What the setting is Every HCP Terraform workspace has an **execution mode**, which decides where Terraform actually runs for that workspace. It is one setting on the workspace's General page, and it does not change the configuration. The same `cloud` block works under all three modes. The value inherits. A workspace's default is **Project Default**, which follows the project's mode. A project in turn defaults to **Organization Default**, which follows the organization's setting. Either level can override, and changing the setting on a workspace requires admin access to it. ## The three modes | | Remote | Agent | Local | |---|---|---|---| | Where Terraform runs | HCP Terraform's disposable VMs | Agents you host | Your workstation or CI worker | | Who manages the run | HCP Terraform | HCP Terraform | You | | Workspace variables | Used | Used | Not evaluated | | What the service does | Runs, state, run features | Runs, state, run features | State storage | | Network direction | Worker must reach your infrastructure | Agent polls outward | Your machine reaches both | ## Remote This is the mode people mean by remote runs, and the one that lets a laptop or pipeline stay free of provider credentials. HCP Terraform performs the run on a **single-use Linux VM**, populates its shell from the workspace's variables and destroys it afterwards. The documentation ties many features to it, including Sentinel policy enforcement, cost estimation, notifications and version control integration. The limit is reachability: on the hosted service, private infrastructure providers you manage must be internet accessible. ## Agent **HCP Terraform agents** solve that reachability problem. An agent runs inside your network, polls HCP Terraform for work and executes it there, so you do not need to allow public ingress to your resources. - Runs stay managed by the service, which is the difference from Local. - Agents belong to an agent pool, and they are a paid feature. - Agents can run custom programs called **hooks** at set points of a run, for example to download software the run needs. - If the policy execution mode is also Agent, the same agent instance evaluates policies and runs Terraform. - `TFE_PARALLELISM` is not supported on agents; set `TF_CLI_ARGS_plan` and `TF_CLI_ARGS_apply` instead. ## Local, and what it gives up Local makes the workspace act only as a remote backend for state. All execution happens on your own workstations or CI workers. It keeps state storage and state versions, and the workspace's permissions still control who may touch that state. Here is what goes: - **Workspace variables and variable sets.** HCP Terraform does not evaluate them, and the Variables page is not available. Values and credentials must already exist wherever Terraform runs. - **Run features.** The documentation lists Sentinel policy enforcement, cost estimation and notifications as unavailable with local operations. - **Version control integration,** which is only relevant with remote execution. - **A consistent run environment.** The Terraform version and any tools are whatever each machine has installed. Local also changes who needs what. Each person needs a user token with **read and write state** on the workspace, and the **lock/unlock workspace** permission, so that local CLI runs can use its state. Those are broader than a Plan role, so Local tends to widen access rather than narrow it. ## Changing the mode safely Changing the mode after a run has already been planned makes that run error when it is applied. The documented sequence minimises that: 1. Disable auto-apply if it is on. 2. Complete any runs that are no longer in the pending stage. 3. Lock the workspace to prevent new runs. 4. Change the execution mode. 5. Re-enable auto-apply if you had it on. 6. Unlock the workspace. The organization's default has a sharper edge: updating it discards operations in progress for workspaces set to inherit it. Announce that change before you make it. ## Choosing - **Remote** when the provider APIs are reachable from the internet and you want the run features. - **Agent** when the targets are private but you still want runs managed centrally. - **Local** when you want HCP Terraform as state storage only, for example while existing pipelines keep executing during a migration.

  • Why might a team moving from an S3 backend start its HCP Terraform workspaces in Local mode?
    Local lets state move first while existing pipelines and their credentials keep executing unchanged, so one risky step happens at a time. The cost is temporary: no workspace variables, no policy enforcement and broader state permissions for each runner. Switching to Remote later means adding provider credentials and variables to the workspaces before the first run.
  • What happens if you change the organization's default execution mode in HCP Terraform?
    Updating it discards Terraform operations in progress for workspaces configured to inherit the default. Workspaces with their own project or workspace setting are not inheriting and keep what they have. Treat it as a scheduled change on a live estate, not a harmless settings tweak.
  • Does an HCP Terraform workspace in Local mode still protect its state from concurrent runs?
    Yes, through the workspace lock. Local CLI runs use the workspace's state and need the lock/unlock permission for it, which is why a Local-mode team must be granted that permission as well as read and write state access.

  • Local mode moves the state back to my disk and ends HCP Terraform's involvement.
  • Variable sets are injected into my shell before each run in Local mode.
  • Agent mode is just Local mode under another name, since both use my machines.
  • Agent mode needs inbound firewall rules so HCP Terraform can reach the agent.
  • Sentinel policies and cost estimation carry on working in Local mode.
  • Changing the execution mode is harmless, because an already planned run carries on.