Skip to content
c3xdevPublic

About

Live examples of c3x: cloud cost estimates on every pull request for Terraform, OpenTofu and CloudFormation

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

Repository files navigation

c3x

c3x demo

See what a pull request costs before you merge it.

Live examples of c3x, the open source cost estimator for Terraform, OpenTofu, Terragrunt and CloudFormation, running on real pull requests.

GitHub Marketplace c3x release

Documentation · CI/CD guide · c3x on GitHub · C3X Cloud app

c3x-cloud bot comment on a pull request: monthly cost increased by $370.34 (+33.2%), from $1115.58/mo to $1485.92/mo, with a per-resource breakdown of the added and resized EC2 instances and a caveat note for the assumed NAT gateway count

Live examples

Open pull requests in this repo, left open on purpose. Each one changes a scenario and gets a cost comment from c3x-cloud[bot].

Pull request Scenario Cost change What it shows
#11 Scale the web tier for launch aws +$370.34/mo An increase that passes the $500/mo budget-delta gate; added vs resized instances
#12 Rightsize the database azure −$368.18/mo A cost decrease, priced in the resource group's region (westeurope)
#13 Add a GPU training cluster aws +$2,781.48/mo ❌ The check fails on budget-delta, after the comment is posted
#14 Scale Cloud Run and GKE for the holiday peak gcp +$390.80/mo Cloud Run minimum instances and a GKE node pool, priced in europe-west1
#15 Expand the edge API to Singapore opentofu +$345.71/mo OpenTofu provider for_each: a new region priced at its own rates

Add c3x to your repo in 60 seconds

Create .github/workflows/c3x.yml:

name: Cost estimate
on: [pull_request]

permissions:
  contents: read
  pull-requests: write # post the comment
  id-token: write      # optional: comment as c3x-cloud[bot]

jobs:
  c3x:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: c3xdev/c3x@v0
        with:
          path: .           # Terraform/OpenTofu directory, plan JSON or CloudFormation template

That's it: no API key, no account, no cloud credentials. On every pull request c3x estimates the base branch and the PR branch and posts the difference. @v0 follows every c3x release.

Comments are posted as github-actions by default. Install the C3X Cloud app on the repository (and keep id-token: write) to have them posted as c3x-cloud[bot], as they are here.

Useful inputs:

Input What it does
budget-delta: "500" Fail the check when the PR adds more than $500/mo
budget: "5000" Fail the check when the monthly total goes above $5,000
strict: true Fail when any number rests on an assumption (⚠ caveat)

The comment is always posted first; a gate that is exceeded then fails the check, as on #13. Add currency: EUR (or any ISO code) to show the comment in another currency.

Several directories on one PR? Give each run its own comment with C3X_COMMENT_TAG (see the workflows in this repo).

Scenarios

One directory per scenario, each with its own workflow that runs only when that directory changes. Totals are c3x's estimates at public on-demand list prices, in USD unless noted.

Directory What's in it What it shows Monthly estimate
aws/ VPC over 3 AZs, NAT gateway per AZ, ALB, EC2 tiers, RDS PostgreSQL Multi-AZ, S3, Lambda module for_each, count from data.aws_availability_zones, dynamic blocks, usage file, .c3x.toml budget, budget-delta gate $1,115.58 ⚠
azure/ AKS (Standard tier), Azure SQL GP_Gen5_4, GRS storage, Linux VM location inherited from the resource group and priced in westeurope $1,451.13
gcp/ Cloud Run with warm instances, Cloud SQL HA, GKE, Compute Engine zone → region pricing (europe-west1-b), Cloud Run minimum instances, regional Cloud SQL $1,341.10
opentofu/ EC2 + ElastiCache in two regions, .tofu files OpenTofu provider for_each, per-region prices $597.59
cloudformation/ EC2, RDS PostgreSQL, S3 CloudFormation templates, strict: true $362.79

⚠ marks estimates where c3x says what it had to assume, on the line itself and in the PR comment, rather than presenting a guess as fact. In aws, the NAT gateways (one per availability zone) assume three zones, because data.aws_availability_zones needs AWS credentials to read; a plan JSON has the real list. See aws/.

Run it locally

brew install c3xdev/tap/c3x        # or: curl -fsSL https://c3x.dev/install.sh | sh
git clone https://github.com/c3xdev/c3x-demo && cd c3x-demo

c3x estimate --path aws                             # per-resource breakdown
c3x estimate --path azure --format json | jq .project_total
c3x estimate --path cloudformation
c3x estimate --path opentofu --currency EUR       # €526.27/mo

c3x reads the code statically: no terraform init, no providers, no credentials. Prices come from pricing.c3x.dev.

How much to trust the numbers

c3x prices at public on-demand list rates, before reserved instances, savings plans, committed-use or negotiated discounts, so treat the totals as an upper bound. Anything that depends on traffic (S3 requests, Lambda invocations, NAT data, load balancer LCUs) comes from a usage file; without one those lines are $0 and marked ⚠. More in the docs.

Links

About

Live examples of c3x: cloud cost estimates on every pull request for Terraform, OpenTofu and CloudFormation

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages