HCP Terraform (formerly Terraform Cloud) is HashiCorp's managed SaaS platform that extends Terraform with team workflows, governance, and scalable infrastructure management. It removes the need to manage remote state or execution environments yourself.
| Objective | Topic | Key Skills |
|---|---|---|
| 8a | Create infrastructure with HCP Terraform | Run lifecycle, workspace types, remote operations |
| 8b | Collaboration & governance features | Teams, SSO, audit logs, Sentinel, OPA, drift detection |
| 8c | Workspaces & projects | Projects, run triggers, variable sets, workspace variables |
| 8d | Configure HCP Terraform integration | cloud block, terraform login, state migration, CLI workflow |
The Planned state awaits operator approval before proceeding to Apply. Terminal error states include Errored, Discarded, and Canceled. Speculative plans (triggered by PRs) never reach Applying — they show proposed changes only.
| Type | Trigger | Use Case |
|---|---|---|
| VCS-driven | Push to configured branch in GitHub/GitLab/Bitbucket automatically triggers a plan | Standard GitOps workflow for teams |
| CLI-driven | Developer runs terraform apply locally; execution happens remotely on HCP Terraform | Developer-initiated remote runs |
| API-driven | Plans/applies triggered via HCP Terraform REST API | CI/CD pipelines, custom automation |
terraform plan executing on HCP agent; logs streamingterraform apply executing; changes being madeTriggered by pull requests in VCS-driven workspaces. They show what would change without requiring approval or applying anything. Results post back to the PR as a check. No state is modified.
When using remote operations, terraform plan and terraform apply execute on HCP Terraform's managed infrastructure — not your local machine. Log output streams back to your browser UI or CLI in real time. Your local machine only needs the cloud block configured and valid credentials via terraform login.
Groups of users within an HCP Terraform organization. Teams receive workspace-level permissions:
| Feature | Detail |
|---|---|
| SSO | SAML 2.0 / OIDC integration with enterprise identity providers (Okta, Azure AD, etc.) |
| Audit Logs | Immutable record of all user actions — who did what, when; exportable for compliance |
| Private Registry | Host private modules and providers; organization-scoped; versioned; same syntax as public registry (source = "org/module") |
HashiCorp's built-in policy framework. Policies are written in the Sentinel language and applied to runs before apply executes.
| Enforcement Level | Behavior | Who Can Override? |
|---|---|---|
| advisory | Logs a warning; run continues | N/A — no block |
| soft-mandatory | Blocks run; organization admins can override | Organization admins |
| hard-mandatory | Blocks run; nobody can override — only policy code change fixes it | Nobody |
Alternative policy framework. Policies written in Rego language. OPA is a CNCF-graduated project widely used outside HashiCorp tooling. Both Sentinel and OPA policies can be organized into policy sets — collections applied to specific workspaces or all workspaces in an organization.
Scheduled checks that compare the Terraform state file to real infrastructure in the cloud. If the two diverge (e.g., someone manually deleted a resource), HCP Terraform alerts on drift without automatically triggering an apply. Part of the broader Health Assessments feature which also runs Sentinel policy checks continuously.
Cross-workspace resource inventory built into HCP Terraform. Lets you search and audit resources managed across all workspaces in an organization from a single view — useful for compliance and sprawl management.
| Concept | Definition | Scopes |
|---|---|---|
| Workspace | Isolated unit of Terraform state; has its own variables, run history, and state file | Individual environment (dev, staging, prod) |
| Project | Logical folder grouping of workspaces; team permissions can be set at the project level | Application, team, or domain |
A run trigger causes Workspace B to automatically queue a plan when Workspace A successfully applies. This models infrastructure dependencies — e.g., a networking workspace finishing before application workspaces start. Run triggers chain workspaces without requiring manual intervention.
Variable sets are named collections of Terraform variables and environment variables that can be shared across multiple workspaces, eliminating copy-paste of common config (e.g., AWS credentials, region). Scope options:
Precedence: Workspace variables override variable sets. TF_VAR_ environment variables set in workspace settings behave identically to CLI environment variables.
Replace a backend block with the cloud block inside terraform {} to connect your workspace to HCP Terraform:
terraform {
cloud {
organization = "my-org"
workspaces {
name = "my-workspace"
}
}
}
After adding the block, run terraform init to set up the remote backend and download providers for remote execution. If migrating existing state, terraform init prompts you to confirm the migration.
| Command | Action | Token Location |
|---|---|---|
terraform login | Authenticates CLI with HCP Terraform; opens browser for token generation | ~/.terraform.d/credentials.tfrc.json |
terraform logout | Removes stored API token from credentials file | Token deleted from above path |
With the cloud block and a valid token, running terraform plan or terraform apply locally submits the run to HCP Terraform where it executes remotely. Log output streams back to the terminal in real time. Your local .tf files define configuration; HCP Terraform manages state and execution environment.
terraform init — configures remote backend; -upgrade flag upgrades providers to newest allowed versions.tf files are uploaded to HCP Terraform for each runThese six patterns cover the most-tested HCP Terraform concepts. Memorize the structures — exam questions test recognition of exact states, levels, and scoping rules.
terraform apply remotely), API-driven (pipeline — triggered via HCP Terraform API).
terraform login = store token in ~/.terraform.d/credentials.tfrc.json. cloud block = point CLI at HCP Terraform org + workspace. Add block → terraform init → ready.
| Level | Blocks Run? | Override Available? | Fix Required? |
|---|---|---|---|
| advisory | No | N/A | No |
| soft-mandatory | Yes | Yes — org admins only | No (admin can bypass) |
| hard-mandatory | Yes | No — nobody | Yes — policy must change |
8 cards covering the most exam-critical HCP Terraform concepts. Click any card to reveal the answer.
cloud block look like and where does it go?terraform {}. Uses organization and workspaces { name = "..." }. Replace any existing backend block. Run terraform init after adding it.terraform login do and where is the token stored?~/.terraform.d/credentials.tfrc.json. Use terraform logout to remove it.terraform apply from their local machine. The plan and apply execute on HCP Terraform's agents, and logs stream to the developer's terminal. Which workspace type is this?cloud block syntax to connect a workspace named prod-infra in organization acme-corp?Select a category to get targeted study guidance for HCP Terraform exam topics.
| State | Description | Terminal? |
|---|---|---|
| Pending | Run queued, waiting for worker | No |
| Planning | terraform plan executing on HCP agent | No |
| Planned | Plan complete; awaiting approval | No |
| Applying | terraform apply executing | No |
| Applied | Run successful; state updated | Yes (success) |
| Errored | Plan or apply failed with error | Yes (failure) |
| Discarded | Operator rejected the plan | Yes (abort) |
| Canceled | Run was canceled mid-execution | Yes (abort) |
| Type | Trigger | VCS Required? | Typical Use |
|---|---|---|---|
| VCS-driven | Push to configured branch | Yes | Team GitOps workflows |
| CLI-driven | terraform plan/apply from CLI | No | Developer-initiated runs |
| API-driven | REST API call to HCP Terraform | No | CI/CD pipelines, automation |
| Level | Blocks Run? | Override? | Who? |
|---|---|---|---|
| advisory | No | N/A | N/A |
| soft-mandatory | Yes | Yes | Org admins only |
| hard-mandatory | Yes | No | Nobody |
| Priority | Source | Notes |
|---|---|---|
| 1 (highest) | Workspace variables | Explicitly set on the workspace |
| 2 | Variable sets | Project-scoped then org-wide |
| 3 (lowest) | Default values in code | From variable definition blocks |
| Command | Purpose |
|---|---|
terraform login | Authenticate CLI with HCP Terraform; stores token |
terraform logout | Remove stored API token |
terraform init | Initialize backend; migrate state when cloud block added |
terraform init -upgrade | Upgrade providers to newest allowed versions |
terraform plan | In CLI-driven: submits remote plan; streams logs to terminal |
terraform apply | In CLI-driven: submits remote apply; streams logs to terminal |
terraform {
cloud {
organization = "my-org"
workspaces {
name = "my-workspace"
}
}
}
Token stored at: ~/.terraform.d/credentials.tfrc.json
| Feature | Key Fact |
|---|---|
| Speculative plans | PR-triggered; no apply; no state change; results post to PR |
| Projects | Logical workspace groups; team permissions set at project level |
| Run triggers | Workspace B auto-queues when Workspace A successfully applies |
| Variable sets | Shared vars across workspaces; workspace vars override |
| Drift detection | Scheduled; alerts on drift; does NOT auto-apply |
| Explorer | Cross-workspace resource inventory |
| Audit logs | Immutable; who did what, when |
| SSO | SAML 2.0 / OIDC only |
| OPA | Rego language; CNCF-graduated alternative to Sentinel |
| Sentinel | HashiCorp-native policy-as-code; Sentinel language |