Cost Estimation
Get infrastructure cost estimates for Terraform plans using Infracost integration.
Cost estimation shows you the monthly cost impact of Terraform changes before you apply them. Cora integrates with Infracost to analyze your plans and display estimated costs alongside risk scores.
How it works
- Configure your API key - Add your Infracost API key in Settings → Integrations.
- Upload a plan - When your CI uploads a Terraform plan, Cora runs Infracost automatically.
- View cost estimates - The PR review shows monthly cost, cost change, and percentage change.
- Create cost rules - Optionally add risk rules that trigger on cost thresholds.
Getting an Infracost API key
Infracost offers a free tier that covers most use cases.
- Sign up at infracost.io.
- Run
infracost auth loginor visit your Infracost dashboard. - Copy your API key (format:
ico-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
Configuring Infracost in Cora
- Navigate to Settings → Integrations.
- In the Infracost section, paste your API key.
- Click Save. Cora validates the key with Infracost before storing it.
Your API key is encrypted at rest using AES-256-GCM. Only the last 4 characters are visible in the UI.
Viewing cost estimates
When a plan is uploaded and an Infracost API key is configured, the PR review detail page displays:
| Field | Description |
|---|---|
| Monthly Cost | Estimated monthly cost after the plan is applied |
| Cost Change | Absolute difference from current cost (positive = increase) |
| % Change | Percentage change from current cost |
Cost increases appear in red. Decreases appear in green.
Infracost estimates are based on published cloud pricing. Actual costs may vary due to reserved instances, savings plans, spot pricing, and usage patterns. Treat estimates as directional guidance.
Plan requirements
For accurate cost estimates, your Terraform plan JSON should include:
- planned_values - The full resource configurations after the plan
- prior_state - The current state before the plan (for cost comparisons)
Plans generated with terraform show -json plan.tfplan include both sections automatically.
If your plan only contains resource_changes without planned_values, cost estimates may be limited or unavailable.
Cost-based risk rules
Once cost estimation is enabled, you can create risk rules that trigger on cost thresholds. This adds cost awareness to your approval workflow.
Available cost fields
| Field | Description | Example |
|---|---|---|
cost.monthly | Estimated monthly cost after the change | cost.monthly greaterThan 5000 |
cost.diff | Absolute cost change in dollars | cost.diff greaterThan 500 |
cost.percentChange | Percentage change | cost.percentChange greaterThan 50 |
Example: High cost increase
Flag plans that increase monthly cost by more than $500:
| Setting | Value |
|---|---|
| Name | High Cost Increase |
| Score | 300 |
| Condition | cost.diff greaterThan 500 |
Example: Major percentage increase
Flag plans that increase cost by more than 25%:
| Setting | Value |
|---|---|
| Name | Major Cost Percentage Increase |
| Score | 200 |
| Condition | cost.percentChange greaterThan 25 |
Example: Expensive infrastructure
Flag plans with total monthly cost exceeding $10,000:
| Setting | Value |
|---|---|
| Name | Expensive Infrastructure |
| Score | 100 |
| Condition | cost.monthly greaterThan 10000 |
Combining cost and resource rules
Cost rules stack with other rules. For example, you might configure:
| Rule | Score |
|---|---|
| Production Account Baseline | +100 |
| Database Instance Change | +200 |
| High Cost Increase (cost.diff > 500) | +300 |
| Total | 600 |
This gives you visibility into both the operational risk (what is changing) and the financial risk (how much more will it cost).
Troubleshooting
Cost data not appearing
- Check API key - Visit Settings → Integrations and verify your Infracost key is configured.
- Check plan format - Ensure your plan includes
planned_values. Runterraform show -json plan.tfplanto generate the full plan. - Check for errors - Infracost may report errors for unsupported resources. These appear in server logs.
Inaccurate estimates
- Usage-based resources - Resources like S3, Lambda, and API Gateway depend on usage patterns. Infracost uses default usage assumptions.
- Regional pricing - Ensure your provider configuration includes the correct region.
- Resource support - Not all Terraform resources have pricing data. Check the Infracost supported resources list.
Next steps
- Configure risk rules to add cost-based scoring.
- Set up plan uploads from your CI pipeline.
- View PR reviews to see cost estimates in action.