Skip to content

c3xdev/c3x

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

C3X

C3X

Cloud cost estimation for Terraform, Terragrunt, and CloudFormation. Includes optimization recommendations, budget guardrails, what-if analysis, and fully offline mode. No API key required.

Docs Release License

C3X cost estimate output

Get started

brew install c3xdev/tap/c3x
c3x estimate --path /path/to/terraform

Or use Docker:

docker pull c3xdev/c3x
docker run --rm -v $(pwd):/workspace c3xdev/c3x estimate --path /workspace

See the quick start guide for more details.

Cost estimates

$ c3x estimate --path examples/terraform --usage-file examples/terraform/c3x-usage.yml

Project: main

 Name                                                        Monthly Qty  Unit              Monthly Cost

 aws_db_instance.postgres
 ├─ Database instance (on-demand, Multi-AZ, db.r5.large)             730  hours                  $365.00
 └─ Storage (general purpose SSD, gp3)                               200  GB                      $46.00

 aws_instance.api
 ├─ Instance usage (Linux/UNIX, on-demand, m5.xlarge)                730  hours                  $140.16
 ├─ root_block_device
 │  └─ Storage (general purpose SSD, gp2)                            100  GB                      $10.00
 └─ ebs_block_device[0]
    └─ Storage (general purpose SSD, gp3)                            500  GB                      $40.00

 aws_nat_gateway.main
 ├─ NAT gateway                                                      730  hours                   $32.85
 └─ Data processed                                        Monthly cost depends on usage: $0.045 per GB

 aws_lb.api
 ├─ Application load balancer                                        730  hours                   $16.43
 └─ Load balancer capacity units                          Monthly cost depends on usage: $5.84 per LCU

 OVERALL TOTAL                                                                                   $650.44

Cost diffs

$ c3x diff --path . --compare-to main

Project: main

 ~ aws_instance.api
   ├─ Instance usage (Linux/UNIX, on-demand, m5.xlarge -> m6i.2xlarge)    +$170.24 ($140.16 -> $310.40)
   └─ ebs_block_device[0]
      └─ Storage (general purpose SSD, gp3, 500 -> 1000 GB)               +$40.00 ($40.00 -> $80.00)

 Monthly cost change: +$210.24 ($650.44 -> $860.68)

Optimization recommendations

c3x recommend --path .
3 recommendation(s) found:

  1. Upgrade to newer instance generation (m5.xlarge -> m7i.xlarge)
     Resource: aws_instance.web (aws_instance)
     The m7i family has better price-performance than m5.

  2. Switch EBS volume from gp2 to gp3
     Resource: aws_ebs_volume.data (aws_ebs_volume)
     gp3 volumes are up to 20% cheaper with better baseline performance.

  3. Consider VPC endpoints to reduce NAT Gateway costs
     Resource: aws_nat_gateway.main (aws_nat_gateway)
     NAT Gateway charges $0.045/GB. VPC endpoints can eliminate these charges.

Budget guardrails

Enforce cost limits in CI/CD pipelines. No paid subscription required.

c3x estimate --path . --budget 1000
c3x diff --path . --compare-to baseline.json --budget-increase 20

What-if analysis

Test cost impact of changes without modifying Terraform code.

c3x estimate --path . --what-if 'aws_instance.web.instance_type=m6i.8xlarge'
c3x estimate --path . --what-if 'aws_db_instance.main.multi_az=true'

PR comments

Post cost estimates in pull requests. Two steps, no secrets.

- uses: actions/checkout@v4
- uses: c3xdev/setup-c3x@v1
  with:
    path: .

Install the C3X Cloud app for branded comments with the C3X logo. See a live example. Also supports GitLab, Bitbucket, Azure Repos, Atlantis, and Spacelift.

Offline mode

Download pricing data once. Estimate without network calls.

c3x pricing sync --providers aws,azure
c3x estimate --path . --offline

Self-hosted pricing API

Run your own pricing API that scrapes directly from AWS, Azure, and GCP.

export C3X_PRICING_API_ENDPOINT=http://localhost:4000
c3x estimate --path .

Supported resources

Over 1,100 Terraform resources across AWS, Azure, and Google Cloud. Usage-based resources (Lambda, S3, data transfer) are supported via usage files.

Roadmap

  • Compare estimates to real cloud bills (AWS Cost Explorer, Azure Cost Management)
  • Pulumi, AWS CDK, Azure Bicep support
  • Historical cost tracking across commits and PRs
  • VS Code and JetBrains inline cost estimates

Contributing

Open a thread in GitHub Discussions before submitting a PR. See the contribution guide for details.

License

Apache License 2.0

About

Open source cloud cost estimation for Terraform, Terragrunt, and CloudFormation

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages