Skip to content
SightLab Cost
Menu
EN

Blog

Terraform cost estimation before you apply

By SightLab editors terraform infracost finops iac estimation

Practical experience with Infracost and similar tools, their limits, and how to fold the estimate into the team’s PR and review process.

Applying Terraform without a cost estimate is like merging a PR without tests. The change may be correct and still be expensive. Tools such as Infracost (and the provider-native estimators) turn the plan into a dollar delta before the apply happens.

I run the estimate on every PR that touches infrastructure and require a human acknowledgement when the monthly delta exceeds a threshold (for us, $50 or 10 %, whichever is larger). The estimate is not perfect—usage-based costs such as data transfer and request volume are only as good as the assumptions—but it catches the large, obvious mistakes: an accidentally large instance type, a multi-AZ database that was meant to be single-AZ, a snapshot policy with “keep forever.”

What the tools are good at

  • Resource prices that are fixed or have clear monthly units (instances, volumes, load balancers, fixed gateway hours)
  • Showing the delta between the current state and the planned state
  • Breaking the cost down by resource so the expensive lines are obvious

What they cannot see

  • Actual data-transfer volume
  • Request rates that drive serverless or API costs
  • Spot interruption behaviour and real realised prices
  • Reserved Instance / Savings Plan discounts that depend on coverage

For those I still rely on the post-apply bill review and the Egress / Serverless calculators with measured numbers.

Folding it into the workflow

# Typical CI step
infracost breakdown --path . --format json --out-file infracost.json
infracost comment github --path infracost.json ...  # posts a comment on the PR

The PR comment becomes the starting point of the review conversation. If the delta is large, the author either justifies it or changes the code before merge.

Cost estimation before apply does not replace the monthly bill review. It prevents the most expensive surprises from ever reaching the bill in the first place.

Dark PR comment or terminal showing Infracost diff with monthly cost delta

I also keep a short allow-list of resource types that are known to be usage-heavy (NAT gateways, high-volume log groups, large data-transfer paths). For those the estimate is treated as a lower bound and the author is asked to supply a rough monthly usage assumption. The combination of automated fixed-cost estimation and explicit usage assumptions has removed the majority of “we didn’t realise it would cost that much” conversations.

Related tools

Related reading

View all posts →