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:
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.micro
instead 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 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.micro
→t3.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
Updated 5 days ago