NEW costerra 0.1.0, the first public release, is out / Apache-2.0 · Rust 1.89+ · Linux & macOS Release notes →

§ 00 Cost estimates for Google Cloud · Terraform & Terragrunt

Know what your Google Cloud costs before you apply.

costerra reads your Terraform and Terragrunt code, prices every resource against the official Cloud Billing catalog in milliseconds, and marks up the bill with ways to spend less. You don't need terraform init or any credentials.

$ cargo install --locked --git https://github.com/echaouchna/costerra
  • 61 ms for 350 resources
  • 0 credentials needed
  • 120+ savings rules
Fig. 1 — costerra breakdown live/, condensed
Analysis time ms 15 projects · 350 resources
Price catalog k SKUs cached locally in 2 MiB
Savings rules + each with a monthly estimate
Resource types priced about 300 more known to be free
Credentials needed static HCL evaluation
Reads Terraform/Terragrunt/plan JSON/Infracost usage files Ships to GitHub Actions/GitLab CI/Docker
§ 01 — Features

A cost survey of your infrastructure, done before your coffee cools.

Fast, accurate and built for CI. costerra fits into the workflow you already have, from your laptop to the merge request.

01

Fast

HCL is evaluated statically and in parallel. There are no providers to download and no plans to wait for.

350 resources
~60 ms
5,000 resources
~100 ms
02

Accurate to the SKU

Prices come from the Cloud Billing Catalog API. costerra applies sustained use discounts, licenses, GPUs, tiered rates, Spot pricing and regional differences.

03

Your contract prices

costerra detects your billing account and prices with your negotiated discounts. Public list prices stay visible next to them.

list
$129.81
yours
$104.20

saves 19.7% against the list price

04

Made for CI

Diff costs against any git ref, post Markdown comments on merge requests, and fail the pipeline when a budget policy is broken.

  1. ✓costerra diff --base origin/main
  2. ✓comment posted on !42
  3. ✗+19% > 15% → exit 2
05

Usage, estimated

Storage, requests and egress get small, medium and large example estimates when you have no usage data yet.

google_storage_bucket.assets$9.00
total with usage$15.21
06

Understands Terragrunt

costerra handles include, dependency outputs, read_terragrunt_config and generate blocks, along with modules, for_each and about 90 built-in functions. If a root module keeps one tfvars file per environment, you get one project per environment.

07

Private by default

Your code is evaluated on your machine and nothing is uploaded. The AI review is opt-in. Before it uploads anything, it redacts secrets, skips git-ignored files and honours .costerraignore. A dry run shows exactly what would be sent.

§ 02 — Method

From .tf to a priced, annotated report, in one command.

Four stations, no network round trips on the critical path. Prices that need refreshing are fetched in parallel while the code is evaluated.

STATION 01

Read

Terraform root modules, Terragrunt units, mixed repositories or a plan.json. costerra discovers the projects for you.

.tf.hcl.tfvarsplan.json
STATION 02

Evaluate

Variables, locals, count and for_each, local and remote modules, and dependency outputs are all evaluated statically and in parallel.

~90 functionsmodulesmock_outputs
STATION 03

Price

Each resource is matched to its SKUs, with your contract prices when they are available. The catalog is split per service and decoded lazily.

85k SKUsSUDSpotfree tiers
STATION 04

Advise

More than 120 rules plus Google Cloud Recommender and Rabbit insights, each with an estimated monthly saving and its source.

tableJSONMarkdownexit codes
§ 03 — Recommendations

Every bill comes back marked up in red ink.

Each finding is matched to the Terraform resource it concerns and comes with an estimated monthly saving. Rules that only make sense outside production, such as Spot, single-zone or no HA, are applied only there.

FindingResourceBeforeAfterSaves / mo
MEDUse Spot VMs for this non-production instance costerra
live/dev/app
google_compute_instance.app[*] ×2
$350.20
$175.10
−$175.10
LOWSwitch n2-standard-8 to e2-standard-8 costerra
live/prod/app
google_compute_instance.app[*] ×4
$999.27
$861.67
−$137.60
ALTCover this always-on VM with a committed use discount costerra
same VMs as above
1-year or 3-year commitment
$999.27
$927.87
alternative
not counted
LOWLifecycle rules to move or delete cold data Google
live/prod/data
google_storage_bucket.datalake
$64.22
$48.16
−$16.06
LOWStatic IP address is not attached to anything Rabbit
live/dev/network
google_compute_address.legacy
$7.30
$0.00
−$7.30

The total counts the best option per resource, so alternatives for the same VM are never added together. Each line names its source: a costerra rule ID, a ready-to-run gcloud recommender command, or a Rabbit link.

Potential savings $0/month
§ 04 — Continuous integration

A cost review on every pull request, with a budget that can say no.

costerra comments on each pull request with the cost diff, then updates that same comment on every push. Policies set the exit code, so a budget can block a merge. diff --base reads the base ref with git archive and never writes to the repository.

costerrabotcommented just now

costerra cost estimate

Monthly cost will increase by $428.10 (+19.0%), from $2,248.49 to $2,676.59.

ProjectBeforeAfterDiff
live/prod/app$1,012.47$1,265.59+$253.12
live/prod/db$642.18$817.16+$174.98
live/dev/app$506.24$506.24$0.00
30-network (prod)$87.60$87.60$0.00
✓ total below $50,000 ✓ increase below $500 ✗ increase above 15% (exit 2)
3 recommendations, potential savings $320.00/month
  • costerra Use Spot VMs for this non-production instance −$175.10
  • costerra Switch n2-standard-8 to e2-standard-8 −$137.60
  • Google Idle IP address legacy-nat −$7.30
.github/workflows/costerra.yml
# abridged: copy the full file from ci/github-actions.yml
name: costerra
on:
  pull_request:
    paths: ["**/*.tf", "**/*.tfvars", "**/*.hcl", "**/costerra*.yml"]
permissions:
  contents: read
  pull-requests: write
jobs:
  cost:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
        with: { fetch-depth: 0 }
      - name: Estimate
        run: |
          costerra pricing sync --if-older-than 7d
          costerra diff . --base "origin/${BASE_REF}" --format markdown --out costerra.md
      - name: Comment   # creates or updates one PR comment
        run: gh api … -F body=@costerra.md
.gitlab-ci.yml
include:
  - remote: https://raw.githubusercontent.com/echaouchna/costerra/main/ci/gitlab-ci.yml

# ✓ runs the published container image (pin it with COSTERRA_IMAGE)
# ✓ re-downloads prices only when the cache is older than 7 days
# ✓ posts, then updates, a single cost comment on the merge request
terminal
$ costerra breakdown . --fail-above 10000
$ costerra diff . --base origin/main \
    --fail-increase-above 500 --fail-increase-percent 10
✗ policy violated: monthly cost increase +19.0% exceeds 10%
$ echo $?
2

# or in costerra.yml (strict: a typo is an error, never a silent no-op)
policies:
  max_monthly_cost: 50000
  max_increase_percent: 15
§ 05 — Coverage

0 priced resource types, and about 300 more known to be free.

From Compute Engine to Vertex AI. Run costerra resources to list every supported type and its usage keys.

  1. Compute Engineinstances, MIGs, autoscalers, disks, Hyperdisk, GPUs, local SSD, reservations, commitments, licenses
  2. GKEStandard & Autopilot clusters, node pools (zones × nodes, Spot, GPUs), Extended channel
  3. DatabasesCloud SQL (HA, replicas, editions), AlloyDB, Spanner, Bigtable, Memorystore, Firestore
  4. StorageCloud Storage (all classes, Autoclass, soft delete), Anywhere Cache, Filestore, Artifact Registry, Backup and DR
  5. NetworkingCloud NAT, load balancers, Cloud Armor, CDN, VPN, Interconnect, egress, NCC, Secure Web Proxy, DNS
  6. ServerlessCloud Run (services, jobs, worker pools, GPUs), Functions gen1/gen2, App Engine, Pub/Sub, Workflows
  7. DataBigQuery (editions, reservations, BI Engine), Dataflow, Dataproc, Composer 1/2/3, Datastream, Dataplex
  8. AI / MLVertex AI Workbench, Colab Enterprise, Vector Search, Feature Store, prediction pools, Cloud TPU
  9. Ops & securityKMS (software, HSM, external), Secret Manager, Logging, Monitoring, Cloud Build, Workstations, IDS
§ 06 — Install

Up and running in under a minute.

Prebuilt binaries for Linux and macOS, a small multi-arch container image, or a build from source.

Rust 1.89 or newer
$ cargo install --locked --git https://github.com/echaouchna/costerra
linux/amd64 · linux/arm64 · non-root
$ docker run --rm -v "$PWD:/work" \
    -v "$HOME/.cache/costerra:/home/nonroot/.cache/costerra" \
    ghcr.io/echaouchna/costerra breakdown .
Linux x86_64/aarch64 · macOS Intel/Apple silicon
# download costerra-<version>-<target>.tar.gz from the releases page, then:
$ sha256sum -c SHA256SUMS --ignore-missing
$ gh attestation verify costerra-*.tar.gz --repo echaouchna/costerra
$ tar xzf costerra-*.tar.gz && mv costerra /usr/local/bin/
Browse releases →
  1. i.
    Sync pricescosterra pricing syncUses gcloud ADC or COSTERRA_API_KEY. This happens automatically on first run.
  2. ii.
    Estimatecosterra breakdown path/to/infraWorks on Terraform, Terragrunt or a plan JSON.
  3. iii.
    Comparecosterra diff path/to/infra --base origin/mainRun it in CI to get a cost comment on every merge request.
§ 07 — Conclusion

Stop guessing your Google Cloud bill.

costerra is free and open source under Apache-2.0. Run it once on your infrastructure repository and see what you could save.