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. Terracotta analyzes resource additions, size changes, and drift re-creations to estimate monthly and annual cost impact.
tc:cost can be enabled in the repository UI to run automatically on every PR, or triggered on demand by commenting tc:cost in any pull request. Cost analysis also runs automatically as part of tc:plan.
💵 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 runs when:
tc:costis triggered manually in a PR commenttc:costis enabled in the repository UI (auto-runs on PR open)- A plan file is generated during
tc:plan(cost is included automatically) - 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:
| Resource | Region | Usage Type | Unit Price | Monthly Cost (730h) | 12-Month Cost | Notes |
|---|---|---|---|---|---|---|
| EC2 t2.micro | us-west-2 | BoxUsage:t2.micro | ~$0.0116/hour | ~$8.47 | ~$101.64 | New instance added |
| EBS gp3 (8GB) | us-west-2 | VolumeUsage.gp3 | ~$0.08/GB-month | ~$0.64 | ~$7.68 | Root volume |
| Existing EC2 (web) | us-west-2 | BoxUsage:t2.micro | unchanged | unchanged | unchanged | Drift 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.microinstead oft2.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 pricing
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.micro→t3.micro,t4g.micro) - Adding lifecycle policies to reduce drift-driven billing overlap
- Removing unused public resources
- Consolidating underutilized volumes
🔇 Zero-Delta Suppression
Terracotta automatically suppresses cost findings when changes don't affect billing-relevant attributes. For example, modifying tags, descriptions, or security group rules on an EC2 instance won't generate a cost finding because those changes don't change the instance's billing profile. This eliminates noisy false positives and keeps the cost report focused on real spending impact.
🌐 Pricing Data Source
Cost estimates are powered by an MCP (Model Context Protocol) AWS Pricing server that queries the AWS Pricing API in real-time. This ensures pricing data is always current and region-accurate.
📋 TL;DR
- Use
tc:costto trigger cost analysis on demand, or enable it in the UI to run automatically on every PR - Estimates monthly and annual deltas from proposed changes
- Zero-delta suppression eliminates noise when changes don't affect billing
- Detects overlap risks and offers optimization guidance
- Output is included in the same PR comment as security, drift, and best-practice findings
Updated 5 days ago
