Skip to main content

Infracost Integration

Overmind's Infracost integration provides real-time cost analysis of your infrastructure changes through our GitHub Action. By analyzing Terraform plans through Infracost's pricing engine, it delivers immediate cost context that helps teams make informed deployment decisions.

image of infracost signal

What This Integration Provides​

The Infracost integration enhances your existing Overmind workflow by:

  • Parallel Cost Analysis: Runs cost calculations simultaneously with blast radius analysis
  • Custom Signal Generation: Transforms cost changes into quantitative signals with graduated severity
  • Financial Risk Context: Shows monetary impact alongside technical risks in PR comments
  • Threshold-Based Alerting: Configurable cost thresholds trigger warnings before deployment

How Cost Signals Work​

Unlike binary policy checks that simply pass or fail, cost signals provide quantitative feedback based on the magnitude of financial change. Each cost modification receives a severity score from -4 to +3:

Severity Scale​

Change TypeSeveritySignal Description
>100% increase-4Critical cost increase
50-100% increase-3High cost increase
20-50% increase-2Moderate cost increase
5-20% increase-1Minor cost increase
5% change-No signal (below threshold)
5-20% decrease+1Minor cost reduction
20-50% decrease+2Moderate cost reduction
>50% decrease+3Significant cost reduction

Changes under 5% are considered normal variation and don't generate signals, keeping your analysis focused on meaningful cost impacts.

Installation​

Prerequisites​

Before setting up the integration, ensure you have:

  • An Overmind account (free signup available)
  • Overmind API key stored as OVM_API_KEY in GitHub secrets
  • Infracost API key stored as INFRACOST_API_KEY (free at infracost.io)
  • Terraform repository with infrastructure code
  • GitHub Pull Request workflow (Custom Signals link to PRs)

Basic Setup​

Add the cost analysis action to your GitHub workflow:

name: Terraform with Cost Analysis
on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
# Your existing terraform analysis continues unchanged
terraform:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: overmindtech/actions/install-cli@main
- uses: overmindtech/actions/submit-plan@main
with:
ovm-api-key: ${{ secrets.OVM_API_KEY }}
plan-json: ./tfplan.json

# Add parallel cost analysis
cost-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3

- name: Generate Terraform Plan
run: |
terraform init
terraform plan -out=tfplan
terraform show -json tfplan > tfplan.json

- uses: overmindtech/cost-signals-action@v1
with:
overmind-api-key: ${{ secrets.OVM_API_KEY }}
infracost-api-key: ${{ secrets.INFRACOST_API_KEY }}
terraform-plan-json: ./tfplan.json

This setup runs cost analysis in parallel with your existing Overmind terraform analysis, providing financial context without slowing down your workflow.

Configuration Options​

Input Parameters​

ParameterDescriptionRequiredDefault
overmind-api-keyYour Overmind API keyYes-
infracost-api-keyYour Infracost API keyNo-
terraform-plan-jsonPath to terraform plan JSONNoAuto-detected
threshold-percentagePercentage change to trigger warningsNo20
threshold-absoluteAbsolute dollar change to trigger warningsNo500
currencyCurrency for display (USD, EUR, GBP)NoUSD
submit-on-decreasesSubmit signals for cost decreasesNotrue
fail-on-thresholdFail if cost exceeds thresholdsNofalse

Advanced Configuration​

For teams with specific cost management needs:

- uses: overmindtech/cost-signals-action@v1
with:
overmind-api-key: ${{ secrets.OVM_API_KEY }}
infracost-api-key: ${{ secrets.INFRACOST_API_KEY }}
terraform-plan-json: './infrastructure/tfplan.json'
threshold-percentage: 10 # More sensitive to changes
threshold-absolute: 100 # Lower dollar threshold
submit-on-decreases: false # Only track increases
fail-on-threshold: true # Block PR on excessive cost
currency: EUR # European currency display

Workflow Integration​

Analysis Process​

When a pull request is created or updated:

  1. Parallel Execution: Cost analysis starts immediately alongside terraform analysis
  2. Infracost Processing: Terraform plan gets analyzed for resource pricing changes
  3. Signal Generation: Cost deltas become Custom Signals with calculated severity
  4. Overmind Aggregation: Cost signals combine with blast radius and risk data
  5. PR Updates: Comments show financial impact with technical context

PR Comment Enhancement​

The integration enriches PR comments with cost information:


## Overmind Analysis

**Cost Changes:** +$142.50/month (+15% increase)
- EC2 instances: +$85.20/month
- RDS storage: +$57.30/month

**Signals:** 3 signals detected
- Cost: Moderate cost increase (-2)
- Policy: No violations detected
- Routine: Following established patterns (+1)

[View detailed analysis →](https://app.overmind.tech/changes/...)

Testing and Validation​

Local Testing​

Test cost analysis locally without API submission:

# Generate terraform plan
terraform plan -out=tfplan
terraform show -json tfplan > tfplan.json

# Run Infracost analysis
infracost breakdown --path tfplan.json
infracost diff --path tfplan.json

Integration Testing​

Test the complete workflow in a pull request environment:

# Set up environment variables
export OVERMIND_API_KEY="your_api_key"
export INFRACOST_API_KEY="your_infracost_key"

# Run action locally using act
act -j cost-analysis --secret-file .env

Troubleshooting​

Common Issues​

Missing Cost Analysis:

  • Verify Infracost API key is correctly configured
  • Check that terraform plan JSON contains resource changes
  • Ensure plan file path matches configuration

Unexpected Cost Calculations:

  • Review Infracost pricing database coverage for your resources
  • Check currency settings match your expectations
  • Validate terraform plan includes all necessary resource details

Signal Submission Failures:

  • Confirm Overmind API key has required permissions
  • Verify pull request context is available
  • Check network connectivity to Overmind services

Debugging Steps​

  1. Validate Infracost Setup:

    infracost --version
    infracost auth status
  2. Test Plan Analysis:

    infracost breakdown --path tfplan.json --format json
  3. Check Action Logs: Review GitHub Actions logs for specific error messages and API responses

Best Practices​

Threshold Configuration​

  • Start Conservative: Begin with default thresholds and adjust based on team feedback
  • Environment-Specific: Use different thresholds for development vs production
  • Team Alignment: Ensure threshold settings match cost management policies

Workflow Design​

  • Parallel Processing: Keep cost analysis separate from terraform analysis for speed
  • Non-Blocking Default: Use informational signals rather than blocking PRs initially
  • Gradual Rollout: Start with tracking-only mode before enabling failure conditions

Cost Management Integration​

  • Regular Review: Periodically assess threshold effectiveness
  • Budget Alignment: Coordinate thresholds with overall infrastructure budgets
  • Optimization Tracking: Use positive signals to measure cost reduction initiatives

Support and Resources​

For additional questions about configuration or integration, join our community or contact support through the application interface.