Skip to content
CloudOps
All prompts
AI for Terraform Difficulty: Intermediate ClaudeChatGPT

Terraform Cost Estimation with Infracost Prompt

Wire per-PR cost estimation into Terraform reviews — surface the monthly delta of every plan, set budget guardrails, and turn cost into a first-class part of code review instead of a surprise on the bill.

Target user
FinOps-minded platform and DevOps engineers
Difficulty
Intermediate
Tools
Claude, ChatGPT

The prompt

You are a FinOps-aware platform engineer who has made Terraform cost visible at review time across dozens of teams.

I will provide:
- My CI platform (GitHub Actions / GitLab CI / Atlantis)
- A sample Terraform plan or root module
- Cloud(s) in use and any committed-use / savings-plan discounts
- Current pain (bill surprises, no per-PR signal, usage-based resources mis-estimated)

Your job:

1. **Pipeline design** — show how to run `infracost breakdown` and `infracost diff` against a plan JSON (`terraform show -json`) so every PR gets a comment showing the monthly cost delta, broken down by resource.

2. **Usage-based resources** — the hard part. Show how to author an `infracost-usage.yml` for the things a plan can't know: data transfer, S3 request counts, Lambda invocations, DynamoDB RCUs/WCUs. Explain which estimates to trust and which to treat as guesses.

3. **Discount accuracy** — explain why list-price estimates over-state cost when you have Savings Plans / Reserved Instances / committed-use discounts, and how to reconcile estimates with actuals.

4. **Guardrails** — define policy thresholds: warn at +$X/mo, require a second reviewer above +$Y/mo, hard-fail on a single resource over $Z/mo. Wire these as a CI gate, not just a comment.

5. **Reviewer workflow** — what a human should actually check in the cost comment (right-sizing, forgotten always-on dev resources, NAT gateways, idle load balancers, over-provisioned RDS).

6. **Drift between estimate and bill** — a monthly habit to compare Infracost projections against the real bill and tune the usage file.

Output as: (a) the CI job/config, (b) a starter `infracost-usage.yml` for my stack, (c) the policy thresholds as enforceable rules, (d) a PR-comment reviewer checklist, (e) the top 5 cost anti-patterns to flag in review.

Bias toward: making the cheap-but-correct choice obvious, and never letting an always-on resource ship without someone seeing the number.
Newsletter

Get weekly AI workflows for DevOps engineers

Practical prompts, automation ideas, and tool reviews for infrastructure engineers. One email per week. No spam.