AI infrastructure cost gate — reads your IaC, no cloud credentials needed
Project description
Oneport Costwatch
An AI infrastructure-cost gate that reads your Infrastructure-as-Code — no cloud credentials needed.
Point it at a repo full of Terraform / Docker Compose and it tells you what's
about to cost you money and how to make it cheaper — before you apply.
It works entirely from the IaC you already have. It never asks for AWS/GCP
keys, never touches your account, and never leaves your machine except for one
call to the model of your choice.
$ oneport-costwatch analyze infra/
Oneport Costwatch
Parsed 4 resource(s); 4 priced. Approx provisioned cost: ~$1,947/mo
Potential savings: ~$791/mo across 4 finding(s)
🔴 CRITICAL aws_instance.api save ~$364/mo (dev-no-shutdown)
Development instances are running 24/7 and can be shut down nights/weekends.
- environment = dev, count = 2 → + add a shutdown schedule (Instance Scheduler)
infra/main.tf:4
🟠 HIGH aws_instance.batch_worker save ~$300/mo (always-on)
A batch worker running 24/7 on on-demand is wasteful for a bursty workload.
- environment = staging → + AWS Batch on Spot, or a schedule
infra/main.tf:28
...
Why not just Infracost?
Infracost is great at one thing: putting a price tag on your Terraform. Costwatch is a different job — it's the judgment layer on top of the price tag:
| Infracost | Oneport Costwatch | |
|---|---|---|
| Price a Terraform plan | ✅ | ✅ (rough, bundled table) |
| Multi-source IaC (Compose too) | Terraform-focused | ✅ Terraform + Docker Compose |
| "This is 4× oversized, here's the right size" | ❌ | ✅ (the wedge) |
| Spot/serverless/shutdown/autoscaling advice | ❌ | ✅ |
| PR gate on cost increase | partial | ✅ sticky comment + exit code |
| Needs cloud credentials | no | no |
Costwatch's estimate is deliberately approximate — if you want a penny-accurate plan cost, run Infracost too. Costwatch is here to catch the waste.
Install
pip install oneport-costwatch
Set a model key. Gemini is free and needs no extra dependency:
export GEMINI_API_KEY=AIza... # free at https://aistudio.google.com/apikey
# or, for Claude:
pip install 'oneport-costwatch[claude]'
export ANTHROPIC_API_KEY=sk-ant-...
Deterministic pricing (oneport-costwatch price) needs no key at all.
Usage
# Analyze a directory of IaC (default: current dir)
oneport-costwatch analyze infra/
# Most accurate source: a Terraform plan you already generated
terraform show -json plan.tfplan > plan.json
oneport-costwatch analyze infra/ --plan plan.json
# Deterministic estimate only — no model call, no key
oneport-costwatch price infra/
# JSON for CI / dashboards
oneport-costwatch analyze infra/ -f json
# Only show the big stuff
oneport-costwatch analyze infra/ -s high
Cost diff on pull requests (the gate)
oneport-costwatch analyze https://github.com/org/repo/pull/42 --post
Costwatch fetches the base and head versions of the changed IaC files,
prices both, and — only if the PR raises provisioned cost past the threshold —
posts a sticky comment explaining "this PR adds ~$340/mo, here's a cheaper
config." Re-runs update the same comment (hidden HTML marker; the PR is the
state store — no server, no database). Add --fail-on-increase to turn it into
a hard CI gate. Needs GITHUB_TOKEN.
See examples/workflows/ for a ready-to-drop GitHub
Actions workflow.
Teach it your rules
Costwatch reads .oneport/guidelines.md (path configurable) and honours it on
every run. For example:
# Cost guidelines
- prod must stay on-demand — never suggest spot for prod resources
- our batch tier is allowed to run large instances overnight
A guideline-driven decision is tagged team-guideline in the output, and
Costwatch will not raise a finding a guideline forbids.
What it parses
- Terraform —
.tffiles (HCL) andterraform show -jsonplan output. Extractsaws_instance,aws_db_instance,aws_ebs_volume,aws_elasticache_cluster,aws_autoscaling_group,google_compute_instance, and more — instance types, storage, replicas, counts, env tags. - Docker Compose — services,
image,deploy.replicas, resource limits.
Unknown instance types are still reported (just without a dollar estimate).
Configuration
Optional .oneport-costwatch.yml in your repo root:
model: gemini-2.5-flash
output:
format: inline # inline | json | github
min_severity: info # info | warning | high | critical
ignore_paths:
- .terraform
- modules/vendored
guidelines_path: .oneport/guidelines.md
post_threshold: 25 # only --post-comment when a PR adds ≥ $25/mo
Env vars: GEMINI_API_KEY / ANTHROPIC_API_KEY, COSTWATCH_MODEL,
COSTWATCH_FORMAT, GITHUB_TOKEN.
Privacy
Serverless and low-trust by design — see PRIVACY.md. In short: no cloud credentials, read-only, runs on your machine. The only thing that leaves your box is the resource inventory sent to your chosen model API, under your own key.
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file oneport_costwatch-0.1.0.tar.gz.
File metadata
- Download URL: oneport_costwatch-0.1.0.tar.gz
- Upload date:
- Size: 33.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab3051b45483efbbf1e8b05fbde2cf8fa786e3e7045840e44b7f1ddc6d77b81a
|
|
| MD5 |
8ab1063666e63e769bcd3a0bd304f220
|
|
| BLAKE2b-256 |
3140e667e98f87423e4a604af20def7987e177a145a012cc7228cad0b0c88a29
|
File details
Details for the file oneport_costwatch-0.1.0-py3-none-any.whl.
File metadata
- Download URL: oneport_costwatch-0.1.0-py3-none-any.whl
- Upload date:
- Size: 38.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6548fd8e849b22340efbc108c63c1da66c522cf7a1b49129e9bffbf61bd5f454
|
|
| MD5 |
6a04a44c1cf4a0d4473bcbe0a1d12eac
|
|
| BLAKE2b-256 |
0d9b908b2e1cb5b588ad17d1962017f507302688fdc5df3744f0c4ed0d1ebb7e
|