Terraform Cloud provides VCS-triggered remote execution, per-workspace state management and access control, and guardrails like policies, cost estimation, and Run Tasks.
This article focuses on VCS, Runs, and workspaces, walking through the key design considerations and the points most often tested on the exam, with concrete examples.
The core unit of Terraform Cloud is the workspace — each one holds a single Terraform state and configuration. When linked to a VCS, branch updates and PRs automatically generate Runs, which proceed through Plan → (Policy/Cost) → Apply.
Remote execution uses Terraform Cloud's managed runtime or an agent, and results are recorded on the workspace. PRs trigger a speculative plan that does not modify state.
Terraform Cloud's logical architecture (VCS → Workspace → Run)
Example repository layout for VCS integration (monorepo)
repo-root/
├── envs/
│ ├── prod/network/ # Workspace: prod-network
│ └── staging/network/ # Workspace: stg-network
└── modules/
└── vpc/
Split workspaces by environment or responsibility — for example, per prod/staging tier, or per component (network/app/db). In a monorepo, use the working directory setting; in a multi-repo layout, mapping each repository 1:1 to a workspace keeps things manageable.
For VCS integration, pin the target branch and working directory, and use trigger prefixes so unrelated changes don't fire Runs. Deliberate tagging and separation along team/project boundaries directly translates into stronger access control, auditability, and observability.
Connecting a Terraform Cloud workspace from the CLI (cloud block)
terraform {
cloud {
organization = "acme"
workspaces {
name = "prod-network"
}
}
}
# 以降は通常の Terraform 設定
module "vpc" {
source = "./modules/vpc"
cidr_block = "10.0.0.0/16"
}
Runs execute serially per workspace; when multiple triggers fire against the same workspace, they queue up. Keep the queue clean by cancelling or discarding stale Runs.
Apply requires sufficient permissions (typically write or higher on the workspace), and unless Auto apply is enabled, a manual approval step is inserted. Speculative plans on PRs don't mutate state, so there's no risk of an accidental apply, but they can still be evaluated by policy and cost checks.
Terraform Cloud workspace configuration (tfe provider example)
provider "tfe" {
hostname = "app.terraform.io"
token = var.tfc_token
}
resource "tfe_workspace" "prod_network" {
name = "prod-network"
organization = "acme"
execution_mode = "remote" # リモート実行
auto_apply = false # 手動承認フロー
}
The Terraform Cloud default is Remote execution, where the SaaS handles the Terraform binary, plugins, and log collection. If you can only reach resources inside a private network, deploy an agent that pulls jobs from Terraform Cloud and runs them locally. If you want CLI-led runs while still using TFC just for remote state and variables, choose Local execution (CLI-driven run).
Your choice depends on whether you prioritize network reach, audit requirements, or execution reproducibility.
| Mode | Execution location | Network reachability | Primary use case |
|---|---|---|---|
| Remote | Terraform Cloud managed | Public endpoints or allow-listed targets | Standard operations; small to mid scale |
| Agent | Self-hosted agent | Private-only OK (outbound connection to TFC) | Air-gapped networks / strict audit |
| Local | Terraform on a developer machine or CI | Depends on the execution environment | Experimentation, development, reusing existing CI |
Creating an agent pool (tfe provider example)
resource "tfe_agent_pool" "priv" {
name = "prod-private-pool"
organization = "acme"
}
# 生成されたトークンでエージェントを起動し、ワークスペースの実行モード=agent/プール=上記を割当
Policies (e.g., Sentinel) let you block dangerous changes based on the Plan output. Cost estimation surfaces a rough cost forecast for major providers and flags threshold breaches. Run Tasks embed third-party security and compliance checks into the Run.
For production workspaces, the combination of baseline policies (mandatory tags, region allow-listing, size caps, etc.) and a cost ceiling is a key topic both on the exam and in real-world operations.
Simple Sentinel policy example (restricting instance types)
import "tfplan/v2" as tfplan
main = rule {
all tfplan.resource_changes as rc {
rc.type != "aws_instance" or
(rc.change.after != null and rc.change.after.instance_type not in ["t2.micro"]) # 例: 特定タイプを禁止
}
}
When infrastructure has dependencies, you can use a successful Apply on an upstream workspace as a trigger to start Plan/Apply on a downstream workspace. This keeps things loosely coupled while automating consistency across environments and components.
In a monorepo, carefully configure working directory and trigger prefixes so that unrelated directory changes don't fire Runs. With a multi-repo layout, you get review, permission, and audit isolation per repository.
Creating a Run Trigger (run downstream after the upstream applies)
resource "tfe_run_trigger" "app_after_network" {
workspace_id = tfe_workspace.app.id # 下流 (起動される側)
sourceable_id = tfe_workspace.network.id # 上流 (トリガー側)
}
Pro
問題 1
On a VCS-connected Terraform Cloud workspace, which of the following best describes what happens automatically when a Pull Request is opened?
正解: A
When a PR is opened, a speculative plan runs and state is not updated. There is no auto-apply, but policy evaluation and cost estimation can still be combined to surface the impact.
What is the difference between Terraform Cloud and OSS Terraform?
Terraform Cloud is a SaaS that provides remote execution, state management, VCS integration, policy and cost estimation, Run Tasks, and access control. With OSS Terraform you run locally or in CI and have to build state management and access control yourself.
Can I use Terraform Cloud without a VCS connection?
Yes. You can trigger Runs via the API or the CLI (Local execution) and let Terraform Cloud handle only state and variable management.
Can I separate state per branch?
The recommended approach is to separate state per workspace. Rather than splitting state dynamically by branch name, create a workspace for each environment or responsibility, and use working directory and trigger settings to support branch-based workflows where needed.
Practice with certification-focused question sets
無料で問題を解いてみるNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
HCL Syntax: Terraform's Configuration Language (2026)
HCL2 fundamentals for Terraform — blocks, attributes, expres...
Terraform Authoring & Operations Pro: Complete Guide (2026)
Tactics for the Terraform Pro exam — module authoring, works...
Terraform Providers: Plugin Management Fundamentals (2026)
Provider mechanics — required_providers, versions, mirrors, ...
Terraform Resource Blocks: Declarative Infra Units (2026)
Resource block fundamentals — addresses, references, common ...
Terraform Data Sources: Read-Only External Data (2026)
Data source basics — declaration, refresh behavior, dependen...