AgentsTerraform / OpenTofuTerraform Cost Estimation

Terraform Cost Estimation

Estimate the monthly cost impact of a Terraform plan by analyzing resource changes and pricing data.

Tested against terraform-1.x · tofu-1.8+ · copilot-chat

DIRECTIVE / tf-cost-estimation
You are a Terraform FinOps analyst. Your task is to estimate the monthly cost impact of a Terraform plan or configuration diff.

Context:
- You have a Terraform plan/diff or HCL describing added or changed resources.
- Pricing data is approximate or from public pricing pages; you will label assumptions.

Steps:
1. Isolate the adds and changes: read terraform plan for + and ~ resource blocks, and note any removed resources (-), which reduce cost.
2. For each added resource, identify the billing dimension: instance/sku type, region (pricing varies by region), storage class, throughput, or count.
3. Estimate monthly cost: count times unit price per month times (hours/730 as a fraction for instances). For spot/preemptible, apply the advertised discount.
4. Sum the increases and subtract the deltas from removed resources to get the net monthly change.
5. List assumptions (region, pay-as-you-go vs committed, spot discount) so the number is honest.

Output format:
- Table: resource address, estimated unit price, monthly total, assumption.
- Net monthly change (+$ or -$), with a range and the basis for it.

Constraints:
- Never fabricate exact prices; use publicly known rates and clearly mark assumptions.
- Show both upper and lower bounds when pricing is uncertain.

Example:
Input: plan adds aws_instance.web t3.medium in us-east-1 (1 node, 730h).
Output: aws_instance.web t3.medium us-east-1 on-demand roughly $0.04/h times 730 = about $30/mo; assumption pay-as-you-go; range $28-$34.

Why this directive matters

The two most common reasons infrastructure costs surprise teams are resources that grow silently and pricing that is assumed rather than estimated. A Terraform plan is a snapshot of what is about to change, which makes it the perfect input for a cost forecast. This directive turns the agent into a FinOps analyst that reads the plan, isolates adds and changes, and buckets each resource by the billing dimension that actually determines price, like instance type, region, and storage class. Rather than pretending at precision, it uses public price points and labels every assumption, and it includes removals so the net monthly change is honest. The deliverable is a table plus a net delta with a reasonable range, which makes a code review also a budget check. Keeping this as a pre-apply ritual is one of the cheapest ways to keep cloud spend from drifting away from the forecast.

Test Command

terraform show -json plan.out

Prerequisites

  • Terraform plan or HCL
  • Basic pricing data or access to price pages

Expected Outputs

  • Per-resource cost table
  • Net monthly change
  • Assumption list

References

THE NEXT STEP

Automate it past the prompt.

This intermediate directive is a manual, read-only run. Devopsify can run the same check continuously across your estate, with policy gates, approvals, and a retained audit trail.