Docs

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

  1. Configure your API key - Add your Infracost API key in Settings → Integrations.
  2. Upload a plan - When your CI uploads a Terraform plan, Cora runs Infracost automatically.
  3. View cost estimates - The PR review shows monthly cost, cost change, and percentage change.
  4. 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.

  1. Sign up at infracost.io.
  2. Run infracost auth login or visit your Infracost dashboard.
  3. Copy your API key (format: ico-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

Configuring Infracost in Cora

  1. Navigate to Settings → Integrations.
  2. In the Infracost section, paste your API key.
  3. 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:

FieldDescription
Monthly CostEstimated monthly cost after the plan is applied
Cost ChangeAbsolute difference from current cost (positive = increase)
% ChangePercentage change from current cost

Cost increases appear in red. Decreases appear in green.

Cost accuracy

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

FieldDescriptionExample
cost.monthlyEstimated monthly cost after the changecost.monthly greaterThan 5000
cost.diffAbsolute cost change in dollarscost.diff greaterThan 500
cost.percentChangePercentage changecost.percentChange greaterThan 50

Example: High cost increase

Flag plans that increase monthly cost by more than $500:

SettingValue
NameHigh Cost Increase
Score300
Conditioncost.diff greaterThan 500

Example: Major percentage increase

Flag plans that increase cost by more than 25%:

SettingValue
NameMajor Cost Percentage Increase
Score200
Conditioncost.percentChange greaterThan 25

Example: Expensive infrastructure

Flag plans with total monthly cost exceeding $10,000:

SettingValue
NameExpensive Infrastructure
Score100
Conditioncost.monthly greaterThan 10000

Combining cost and resource rules

Cost rules stack with other rules. For example, you might configure:

RuleScore
Production Account Baseline+100
Database Instance Change+200
High Cost Increase (cost.diff > 500)+300
Total600

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

  1. Check API key - Visit Settings → Integrations and verify your Infracost key is configured.
  2. Check plan format - Ensure your plan includes planned_values. Run terraform show -json plan.tfplan to generate the full plan.
  3. 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