c3x

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

README

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

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 using the setup action. Install the C3X Cloud app for branded comments.

- uses: c3xdev/setup-c3x@v1
  id: c3x
- run: c3x comment github --path . --github-token ${{ steps.c3x.outputs.token }}

Supports GitHub, 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_SELF_HOSTED=true
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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetReferenceUsageFileContents

func GetReferenceUsageFileContents() *[]byte

Types

This section is empty.

Directories

Path Synopsis
cmd
c3x command
jsonschema command
resourcecheck command
resourcegen command
internal
hclstack/codegen
Contains routines for generating terraform code
Contains routines for generating terraform code
hclstack/collections
Package collections provides generic collection utility functions.
Package collections provides generic collection utility functions.
hclstack/errtrace
Package errtrace provides error wrapping with stack trace capture.
Package errtrace provides error wrapping with stack trace capture.
hclstack/fileutil
Package fileutil provides file system utility functions.
Package fileutil provides file system utility functions.
hclstack/terraform
Package tfr contains functions and routines for interacting with terraform registries using the Module Registry Protocol documented in the official terraform docs: https://www.terraform.io/docs/internals/module-registry-protocol.html
Package tfr contains functions and routines for interacting with terraform registries using the Module Registry Protocol documented in the official terraform docs: https://www.terraform.io/docs/internals/module-registry-protocol.html
hclstack/verutil
Package verutil provides version information for the hclstack module.
Package verutil provides version information for the hclstack module.
localpricing
Package localpricing provides a local SQLite-based pricing database for offline cost estimation.
Package localpricing provides a local SQLite-based pricing database for offline cost estimation.
modsource
getter is a package for downloading files or directories from a variety of protocols.
getter is a package for downloading files or directories from a variety of protocols.
recommend
Package recommend provides cost optimization recommendations based on estimated resources.
Package recommend provides cost optimization recommendations based on estimated resources.
ui
vcs
whatif
Package whatif provides resource attribute override functionality for cost scenario analysis.
Package whatif provides resource attribute override functionality for cost scenario analysis.
tools
describezones command
release command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL