HCP Terraform / Enterprise Operations · Topic 1 of 3
Operating HCP Terraform, Usage and Cost
Terraform Professional (002): HCP Terraform run workflows and stages, health assessments, Stacks versus workspaces, managed resources and cost estimates.
- 5 min
- Uploading a configuration version creates a run automatically.
- Speculative plans can never be applied.
- Health assessments report and never change infrastructure; you resolve drift.
What it is
HCP Terraform (formerly Terraform Cloud) and Terraform Enterprise run Terraform for you and store state. Operating the platform means choosing how runs start, reading what each stage reports, watching workspace health after the apply, and tracking how many resources you manage and what a change may cost.
How it works
Choosing a run workflow
| Workflow | Starts when | Best for |
|---|---|---|
| VCS driven | A commit or pull request reaches a connected repository | Git-based review |
| CLI driven | Someone runs terraform plan or terraform apply with a cloud block | Local control with remote runs |
| API driven | A tool uploads a configuration version | A CI system deciding when to run |
The API workflow has three steps: create a configuration version, upload a .tar.gz of the configuration to the returned URL, and let HCP Terraform create the run automatically. The token needs permission to queue plans, and applying through the API needs apply permission.
When a VCS repository is connected to the workspace, direct uploads work only for speculative plans.
Run stages
Each optional stage runs only if it is configured. Run tasks connect third-party tools at the pre-plan, post-plan, pre-apply and post-apply stages, with advisory or mandatory enforcement, and post-apply tasks are advisory only.
Policies evaluate only after a successful plan. Speculative plans cannot be applied, skip the workspace run queue and cannot become the current run.
Health assessments
| Feature | Checks | Reported under |
|---|---|---|
| Drift detection | Out-of-band changes that conflict with configuration | Health > Drift |
| Continuous validation | precondition, postcondition and check blocks still pass | Health > Continuous validation |
Requirements are the Standard or Premium edition, remote or agent execution mode, at least one successful apply, and a latest run that did not error. Assessments pause if the latest run errored, was canceled or was discarded.
They use non-actionable, refresh-only plans and never modify infrastructure. To resolve drift, either apply the configuration to overwrite it or update the configuration to keep the change. Drift detection covers only attributes defined in the configuration, so set critical attributes explicitly.
Organization owners can enforce assessments for all eligible workspaces, which overrides workspace settings. Otherwise a workspace admin enables them under Settings > Health.
Stacks or workspaces
| Choose | When |
|---|---|
| Workspaces | One root module, strict environment separation, gated promotion, policy as code, drift detection, run tasks, run triggers |
| Stacks | Large multi-component infrastructure repeated across regions or accounts, with deferred changes and orchestration rules |
Workspaces are not coupled to each other, so they rely on run triggers or other automation. Sentinel and OPA policy sets apply to workspaces only.
Other daily operations
- State versions: the States tab shows each version with its run, commit and diff. Rollback needs a workspace lock and can orphan resources, so review differences first.
- Locks: a locked workspace blocks applies. A user who can lock cannot unlock another user's lock, but a workspace admin can force unlock.
- Explorer: queries across the organization by Workspaces, Modules, Providers and Terraform Versions, for example to find drifted workspaces.
Tracking usage: managed resources
The Usage page shows how many resources you manage, counted from all state files. Each instance counts, so trace it rather than counting blocks.
resource "aws_subnet" "app" {
for_each = toset(["a", "b", "c"])
vpc_id = var.vpc_id
cidr_block = var.cidrs[each.key]
}
data "aws_ami" "base" {
most_recent = true
owners = ["amazon"]
}
resource "terraform_data" "marker" {}
This workspace counts 3 managed resources. The three subnet instances count individually, whereas the data source and the terraform_data resource are excluded, as are null resources. Resources inside modules count too.
Tracking cost: cost estimation
Cost estimation is off by default. You enable it in the organization's Settings > Cost Estimation, and every run then shows a stage between plan and apply.
It lists hourly and monthly cost per resource plus the monthly change, for AWS, Azure and GCP resources, and it lists resources it cannot estimate. Results are estimates, not guarantees, especially for usage-based pricing.
The tfe provider's tfe_organization data source reads organization settings such as cost_estimation_enabled, so a configuration can check them.
A Sentinel policy can read the cost change through the tfrun import, for example to block a run that adds too much monthly cost. This works only in legacy policy checks, not in agent-based policy evaluations.
How the exam asks about this
- "A CI tool must decide when HCP Terraform runs." Use the API driven workflow with a configuration version.
- "Someone changed a security group by hand, and the team wants to be told." Enable health assessments; they report drift but do not fix it.
- "A workspace has 10 instances from
count, 2 data sources and a null resource." It counts 10 managed resources.
What to remember for the exam
- Uploading a configuration version creates a run automatically.
- Speculative plans can never be applied.
- Health assessments report and never change infrastructure; you resolve drift.
- Continuous validation evaluates custom conditions, and
checkblocks suit post-apply monitoring. - Managed resources count each instance and exclude data sources,
terraform_dataand null resources. - Cost estimation is off by default and is enabled at the organization level.
A failed latest run pauses health assessments for that workspace. They resume only after a successful apply, so a workspace stuck in error is not being watched.
Common mistakes
Expecting drift detection to correct drift. It only reports. A person must apply the configuration or update it to accept the change.
Counting resource blocks instead of instances. A single block with for_each over three keys is three managed resources.
Treating a cost estimate as a bill. It is an estimate, and some resources have no price data. Use it to compare changes and to drive policy.
Check yourself
What happens after you upload a configuration archive through the API?
HCP Terraform automatically creates a new run with a plan, and it applies only if the workspace auto-applies or an apply is requested.
Do health assessments change infrastructure?
No. They run non-actionable plans and report results, so resolving any drift remains your decision.
Which items are excluded from the managed resource count?
Data sources, null resources and
terraform_dataresources are excluded, while each instance fromcountorfor_eachcounts.
Topic 1 of 3 in HCP Terraform / Enterprise Operations
Test yourself on HCP Terraform / Enterprise Operations
The full HashiCorp Terraform Infrastructure Engineer Professional question bank has 600 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by HashiCorp. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.