Run Workflows and Remote Operations
HCP Terraform runs Terraform in workspaces, started from version control, the CLI or the API. This lesson covers the three workflows, the stages of a run and the execution modes.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish VCS-driven, CLI-driven and API-driven workflows.
- Describe the stages of a run and the execution modes.
- Explain workspace variables and their categories.
Three workflows
Every run happens in a workspace, which holds one configuration's state, variables and settings. HCP Terraform supports three ways to start runs, and a workspace is set up for one of them.
| Workflow | How runs start | Typical use |
|---|---|---|
| VCS-driven | Commits to a connected branch; pull requests start speculative plans | Teams that review changes in a Git provider |
| CLI-driven | terraform plan and terraform apply from a local terminal or CI job | Existing scripts and pipelines; local iteration with remote state |
| API-driven | Other tools upload configuration versions and create runs through the API | Custom orchestration and integrations |
In the VCS-driven workflow, the workspace is connected to a repository, branch and optionally a working directory in GitHub, GitLab, Bitbucket or Azure DevOps. A merge to the branch queues a plan. A pull request starts a speculative plan, a plan-only run that can never be applied, and its result appears as a status check on the pull request so that reviewers see the impact before merging.
The following diagram follows a change through a VCS-driven workspace.

Which run workflow?
The stages of a run
A run moves through a fixed sequence of stages. Runs in one workspace are processed one at a time from a queue, which together with built-in state locking prevents conflicts.
-
Pending
The run waits in the workspace queue.
-
Plan
Terraform runs plan on a worker; optional pre-plan and post-plan run tasks call external services.
-
Cost estimation and policy check
Where enabled, estimated cost changes are shown and Sentinel or OPA policies are evaluated.
-
Confirm
A user with permission approves the apply, unless the workspace has auto-apply enabled.
-
Apply
Terraform applies the plan; pre-apply and post-apply run tasks can run around it.
Each run keeps its logs, plan, policy results and the state version it produced, which gives a full audit trail.
Execution modes and variables
A workspace's execution mode decides where Terraform runs. Remote, the default, uses disposable workers managed by HashiCorp. Agent runs on HCP Terraform agents that you deploy in your own network, for infrastructure that is not reachable from the internet. Local runs Terraform on the user's machine, with HCP Terraform storing state only; in local mode, workspace variables are not used.
Workspace variables come in two categories: Terraform variables, which set input variables like a .tfvars file, and environment variables, which are set in the run environment, typically for provider credentials such as AWS_ACCESS_KEY_ID or settings such as TF_LOG. Either can be marked sensitive, which makes it write-only: it can be used by runs and overwritten, but not read back in the UI or API. Because credentials live in the workspace, users can plan changes without holding production credentials themselves.
- Speculative plan
- A plan-only run, for pull requests or CLI plans, that cannot be applied.
- Execution mode
- Remote, agent or local: where a workspace's Terraform operations run.
- HCP Terraform agent
- A self-hosted process that runs workspace operations inside a private network.
Execution modes and variables
Reviewing infrastructure changes
A team wants every infrastructure change reviewed in GitHub with its plan visible, applies to happen only after merge, and no developer to hold AWS credentials.
The decisive requirements are pull request plans and central credentials.
A VCS-driven workspace connected to the repository's main branch meets all three. Pull requests trigger speculative plans whose results appear as checks; merges queue runs that apply after approval; and the AWS credentials, or better, dynamic provider credentials, are configured in the workspace, so developers never need them.
What kind of run does a pull request start in a VCS-driven workspace?
Show answer
A speculative plan, which shows the changes but cannot be applied.
Exam Tips
Remember for the exam
- Workflows: VCS-driven, CLI-driven, API-driven.
- Pull requests produce speculative plans that cannot be applied.
- Run stages: plan, cost estimation, policy check, apply.
- Execution modes: remote (default), agent, local.