Cost Analysis
Cost Analysis estimates what the infrastructure in your Terraform state costs, per resource, per state, and across your whole tenant. Each estimate is stored as a cost snapshot you can read over the API, attribute by tag, chart over time, and query with SQL.
Because Stategraph already holds your fleet's state of record, it can answer questions a per-file editor plugin can't: what a whole environment costs, who owns that spend, and how it is trending.
Features
State and Resource Cost
Price a single state and read a per-resource, per-component breakdown.
Plan-Time Cost
See a change's cost delta inline at stategraph tf plan, before you apply it.
Cost Attribution
Roll up cost by provider, resource type, and tag (owner, team, environment) across every managed state, and track it over time.
Cloud Billing
Ingest your actual cloud spend from a FOCUS billing export to work with real billed cost, not just estimates.
How It Works
Stategraph prices each resource by calling a pricing service backed by a price book of cloud pricing data. You enable it once per deployment (see Setup).
Each estimate is written as a cost snapshot: per-state totals (cost, coverage, currency) plus a per-resource breakdown of monthly and hourly cost, pricing components, and tags. Snapshots are recomputed on a schedule, after an apply, and on demand.
Monetary values are returned and stored as strings to preserve sub-cent precision, so parse them as decimals rather than floats. A money field is absent when nothing in that scope is priced.
Estimates, Not Bills
Cost figures are list-price estimates computed from each resource's type and attributes (instance class, storage size, region), not your metered cloud bill. They are ideal for comparing options, catching expensive changes, and attributing spend, but they will not match your invoice to the cent. To work with real billed spend, connect a cloud billing export.
Coverage
Not every resource can be priced. Each resource in a snapshot falls into one of three states:
| State | Meaning |
|---|---|
| Priced | Supported, and a cost was found; contributes to the totals |
no_price |
Recognized, but nothing is billable (for example, an aws_db_subnet_group) |
| Unsupported | No pricing model exists for the type |
coverage_percent reports the share of resources that were priced. Only priced resources contribute to the totals, so read a total alongside its coverage, and list the gaps with the unsupported endpoint.
Documentation
| Topic | Description |
|---|---|
| Setup | Enable cost analysis: the pricing service and price book |
| State & Resource Cost | Price a state and read the per-resource breakdown |
| Plan-Time Cost | Preview a change's cost delta before you apply |
| Cost Attribution | Tenant rollups, attribution by tag, and trends |
| Querying Cost Data | SQL over the cost snapshot tables |
| Cloud Billing (FOCUS) | Ingest your actual cloud spend |