Infrastructure cost modeling
Start with usage, not the resource count
Terraform describes infrastructure and proposes changes; most billing systems charge for measured usage, capacity, requests, time or other service-specific dimensions. One resource can produce several charges, and one charge can be shared across resources. FinOps brings engineering, finance and product teams together to make cost and value decisions. Start with a fictional catalog service running two virtual machines for a 30-day month. Multiply quantities by rates with matching units and add only priced line items. The following original prices are invented USD values dated 2026-11-28, not quotes from a cloud provider.
Fictional monthly worksheet — USD, 30 days, synthetic rates dated 2026-11-28Item Quantity USD/unit USDCompute 2 x 720 instance-hours 0.05 72.00Block storage 100 GB-month 0.10 10.00Internet egress 200 GB 0.09 18.00Gateway 720 hours 0.04 28.80Gateway processing 100 GB 0.04 4.00Logs 20 GB 0.50 10.00Backup storage 50 GB-month 0.08 4.00API requests 2 million 0.40 0.80Known subtotal 147.60Support, taxes, platform fees, cross-zone transfer: not pricedThe known subtotal is $147.60. It is not a complete bill: the unpriced rows require investigation. A real estimate needs the service SKU, region, currency, rate date, billing period, unit definition (GB versus GiB), discount assumptions and the usage source.
Model demand and uncertainty
Separate fixed-for-the-scenario items from variable usage. Here, doubling internet egress from 200 to 400 GB while holding the other assumptions fixed adds $18.00. In real systems, increased traffic could also change gateway processing, requests, logs or compute requirements. Use low, expected and high scenarios and document correlations. Do not equate 720 hours with a universal billing month; actual calendar months vary and a provider may use another normalization.
Egress 100 GB: 129.60 + 9.00 = 138.60 USDEgress 200 GB: 129.60 + 18.00 = 147.60 USDEgress 400 GB: 129.60 + 36.00 = 165.60 USDThe $129.60 baseline excludes internet egress, not all network charges. Include NAT, inter-zone and cross-region transfer separately if applicable; avoid charging the same traffic twice for one billing dimension, while recognizing different services can each charge for it.
Create an inspectable Terraform cost model
The included local fixture models a worksheet as expressions, not a deployment. It needs no external provider or cloud credentials. In a fresh disposable directory, inspect main.tf and the supplied terraform.tfvars. With an approved compatible CLI, initialize with no remote backend, validate and inspect a plan; do not apply. This configuration has only outputs. Its expected result with the supplied 400 GB input is 165.60 USD numerically (display may omit trailing zeros). The unpriced list remains separate.
variable "egress_gb" { type = number default = 200 validation { condition = var.egress_gb >= 0 error_message = "Egress must be non-negative." }}
locals { # Invented rates in USD, not a provider price catalog. line_items = { compute = 2 * 720 * 0.05 storage = 100 * 0.10 egress = var.egress_gb * 0.09 gateway = 720 * 0.04 processing = 100 * 0.04 logs = 20 * 0.50 backup = 50 * 0.08 requests = 2 * 0.40 }}
output "known_subtotal_usd" { value = sum(values(local.line_items))}
output "unpriced_items" { value = ["support", "taxes", "platform fees", "cross-zone transfer"]}The fixture has not been executed in Terraform. For currency reporting, use an explicit precision and rounding rule, and reconcile with the actual billing system. The accompanying Python fixture uses decimal arithmetic and cents for exact checks; that is not evidence that a Terraform run succeeded.
Review the plan estimate, not just the delta
HCP Terraform can add a cost-estimation stage for supported resources when available and enabled. Examine the estimated total, difference from baseline and unestimated items. A separate tool such as Infracost can incorporate usage assumptions for certain resources. Neither sees every future operation or automatically knows actual demand, negotiated pricing or every external charge. Verify current tool support, entitlement, data transfer and privacy before sharing a plan. The native CLI plan is not a complete cloud price calculator.
Baseline estimate (known items): 147.60 USDProposed estimate (known items): 165.60 USDDelta: +18.00 USDUnpriced: support, platform fees, tax, cross-zone transferDecision: obtain missing evidence before full-cost approvalA zero estimate for an unsupported item is not proof that it is free. Check managed control-plane fees, public IPs, software licenses, backups, logs, support and IaC service fees. In HCP Terraform, cost-estimate access by policies depends on execution mode; verify the documented mode rather than assuming all policies can read it.
Distinguish estimate, forecast and invoice
An estimate represents a scenario; a forecast predicts future spending from usage trends and planned changes; an invoice records billed charges under the applicable contract and billing cycle. Reconcile all three at a consistent scope and currency, accounting for credits, discounts, commitments and taxes. A commitment can reduce rates for eligible usage but create a financial obligation even if demand falls. Evaluate utilization risk and contract terms with authorized finance staff; never automatically purchase capacity based on a plan.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Infrastructure cost modeling — knowledge check
Review infrastructure cost modeling and cost-control limitations.
What does a known subtotal of $147.60 with unpriced rows represent?
If only egress increases by 200 GB at $0.09/GB, what is the delta?
What belongs in a real estimate?
An estimator cannot price a managed resource. What should happen?
Which describes a forecast?