IaC Cost estimation in your PR

Terracotta AI helps DevOps and platform engineers understand the cost implications of proposed infrastructure changes in a pull request. When terraform plan is available (i.e., credentials are configured), Terracotta analyzes resource additions, size changes, and drift re-creations to estimate monthly and annual cost impact.

📌

Note: There is no tc:cost command at this time, cost analysis is automatically included when triggered by a plan file or review context that changes resource footprint.


💵 When Cost Analysis Runs

Terracotta supports in-depth, scenario-based cost estimation when asked directly in a PR comment. This includes projections such as:

  • 12-month cost forecasts
  • Total cost across multiple added resources
  • Comparisons between instance types or configurations

Example prompt: @try-terracotta in this diff, what is the cost impact of my changes and what would it look like 12 months out.

Cost analysis is included in PR reviews when:

  • A plan file is generated during tc:plan or initial PR indexing
  • Resources are added, deleted, or resized
  • Drift correction may lead to temporary cost overlap (e.g., re-creating EC2 instances)

📊 What the Report Contains

1. Summary Table: Cost Estimates (Dynamic Based on Question)

Terracotta analyzes the plan and calculates deltas for new and modified resources:

ResourceRegionUsage TypeUnit PriceMonthly Cost (730h)12-Month CostNotes
EC2 t2.microus-west-2BoxUsage:t2.micro~$0.0116/hour~$8.47~$101.64New instance added
EBS gp3 (8GB)us-west-2VolumeUsage.gp3~$0.08/GB-month~$0.64~$7.68Root volume
Existing EC2 (web)us-west-2BoxUsage:t2.microunchangedunchangedunchangedDrift re-creation, same cost profile

🧠 AI Comment Content

The AI-generated cost comment includes:

  • Breakdown of new vs existing resources
  • Dynamic estimates (monthly by default, 12-month if asked)
  • Identification of transient overlaps (e.g., during create-before-destroy)
  • Warnings about public exposure risks tied to cost (e.g., unused public instances)
  • Optional savings recommendations (e.g., consider t3.micro instead of t2.micro)

🧮 How Estimates Are Calculated

Terracotta calculates costs based on usage assumptions and region inferred from your Terraform configuration:

  • Region: inferred from provider config (e.g., us-west-2)
  • Runtime: 730 hours/month
  • Pricing model: On-Demand only (for now)

If pricing data is unavailable:

“Pricing data is not available for this usage type or region.”


💡 Cost Optimization Tips

Terracotta may suggest:

  • Replacing instance types (e.g. t2.microt3.micro, t4g.micro)
  • Adding lifecycle policies to reduce drift-driven billing overlap
  • Removing unused public resources
  • Consolidating underutilized volumes

📋 TL;DR

  • Cost analysis is automatic, no tc:cost command needed
  • Estimates monthly and annual deltas from proposed changes
  • Detects overlap risks and offers optimization guidance
  • Output is included in the same PR comment as security, drift, and best-practice findings