nebius-tf-cost
Estimate Nebius AI Cloud costs from Terraform plan or state JSON — no Nebius account credentials required.
Uses a vendored public price catalog (data/prices.json) derived from Nebius docs. Supports min/max total estimates and plan deltas, optional --strict-check gating on the max (pessimistic) figure / missing usage / unknown types, hour/month/year periods, and planned usage for usage-based resources (Object Storage, MK8s node counts, Serverless AI duty cycle, local SSD size).
Version: SemVer 1.0.0 (stable CLI for CI). See CHANGELOG.md; bump process in CONTRIBUTING.md. nebius-tf-cost --version reports the installed package version.
Install
From PyPI (once the v* release publish has succeeded):
pip install nebius-tf-cost
nebius-tf-cost --version
From source (development / before PyPI is live):
git clone https://github.com/yacompsci/nebius-tf-cost-estimate.git
cd nebius-tf-cost-estimate
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
Or without cloning:
pip install "git+https://github.com/yacompsci/nebius-tf-cost-estimate.git"
Demo
Uses the committed sample plan and usage file (no Terraform required):
nebius-tf-cost estimate \
--plan examples/sample-plan.json \
--usage-file examples/usage.yaml \
--period month \
--budget 5000
Expected: prints before/after/delta min and max totals, line items, warnings for unpriced or zero-usage resources, and a budget verdict gated on max. Add --strict-check in CI to fail on budget exceed, missing planned usage, or unknown/unpriced resources.
--mode controls whether those totals are a delta (Before / After / Delta) or a total (After only, Before=0). It does not choose the input file — still use --plan / --state / --input for that.
--mode |
Behavior |
|---|---|
auto (default) |
Plan JSON → delta + after; state JSON → total. Matches what those inputs contain (plan has before/after; state is current inventory). |
total |
Force after-only even on a plan (proposed bill without the change). |
plan |
Keep before/after for delta. |
state |
Same aggregation as total (after-only) — effectively an alias; auto + a state document already resolves to total. |
Useful override: after-only on a plan file:
nebius-tf-cost estimate --plan examples/sample-plan.json --mode total --period month
On a state run, auto already means total (Before stays 0):
nebius-tf-cost estimate --state state.json --period month
More copy-paste pairs: examples/usage/README.md.
To estimate your stack, export plan JSON and pass that same path:
terraform plan -out=tfplan
terraform show -json tfplan > plan.json
nebius-tf-cost estimate --plan plan.json --usage-file examples/usage.yaml --period month
CI-friendly test command
pip install -e ".[dev]"
python -m pytest
ruff check src tests scripts
ruff format --check src tests scripts
Or via Make:
make check # pytest (excludes e2e) + ruff
make cov # pytest with coverage (pytest-cov in [dev])
make e2e # plan-only Terraform e2e (@pytest.mark.e2e)
Or as a single gate:
python -m pytest && ruff check src tests scripts && ruff format --check src tests scripts
Default pytest excludes @pytest.mark.e2e (offline/fast). Plan-only Terraform e2e (real init/plan/show -json → estimate; no Nebius credentials, never apply) lives under tests/e2e/terraform/:
# requires terraform on PATH; skips locally if missing
make e2e
# or: python -m pytest -m e2e -o addopts=-q
Flags (summary)
| Flag | Description |
|---|---|
--plan / --state / --input |
Terraform JSON source (mutually exclusive) |
--mode auto|plan|state|total |
Frame totals as delta or after-only (default auto; see Demo). Does not select the input file |
--period hour|month|year |
Totals period (month = 730h per Nebius docs) |
--currency USD|ILS |
Catalog currency |
--budget AMOUNT |
Budget in --currency for the selected period |
--strict-check |
Fail (exit 2) if max exceeds --budget, planned usage is missing, or unknown/unpriced resources are present; default is warn + exit 0 |
--budget-compare after|delta|abs_delta |
Which max figure to gate (after_total_max, delta_max, or worst abs delta) |
--usage-file PATH |
YAML/JSON planned usage |
--usage-metric KEY=VALUE |
Default usage overrides (repeatable) |
--catalog-price KEY=VALUE |
Quote / missing catalog rates (repeatable); see docs/catalog-price.md |
--catalog PATH |
Override vendored prices.json |
--preemptible-policy on_demand|floor|reject |
Spot: on_demand → min floor / max on-demand; floor → both at published floor; reject → unknown |
--json |
Machine-readable report |
--include-zero |
Show free/zero line items |
nebius-tf-cost estimate --help
Planned usage
Object Storage, MK8s node counts, Serverless AI duty cycle, and local SSD size are not fully encoded in Terraform. Pass planned metrics with --usage-file / --usage-metric.
See docs/usage-file.md for the file shape, metric table, and lookup order.
Copy-paste patterns (clear missing-usage warnings without tribal knowledge):
| Example | Covers |
|---|---|
| examples/usage.yaml | Short Object Storage demo for examples/sample-plan.json |
| examples/usage/gpu-nodes.yaml | GPU node counts / Serverless utilization / local SSD |
| examples/usage/object-storage-egress.yaml | Storage + requests + egress |
| examples/usage/preemptible-mix.yaml | On-demand + spot fleet overlays + --preemptible-policy |
Index: examples/usage/README.md.
Quote-only / missing catalog rates
GB200/GB300 platforms, VAST, and NETWORK_HDD have no public list price in the vendored catalog. Supply a private rate with --catalog-price (same KEY=VALUE repeatable style as --usage-metric):
nebius-tf-cost estimate --plan plan.json \
--catalog-price VAST=0.12 \
--catalog-price platform.GB200=25 \
--catalog-price disk.NETWORK_HDD=0.05
See docs/catalog-price.md for key vocabulary, units, and override-vs-public-rate behavior. WEKA USD ($0.10/GiB·month) is vendored from nebius.com/prices.
Exit codes
| Code | Meaning |
|---|---|
| 0 | Success (warnings only unless --strict-check) |
| 2 | --strict-check failed (budget exceeded, missing planned usage, or unknown resources) |
| 64 | Bad flags / missing input paths |
| 65 | Invalid plan/state/catalog/usage data |
| 70 | Unexpected internal error |
Module layout
| Module | Responsibility |
|---|---|
cli.py |
argparse, formatting, exit codes |
config.py |
Typed EstimateConfig / PlannedUsage |
catalog.py |
Load vendored prices |
terraform.py |
Parse plan/state JSON |
estimate.py |
Resource estimators + totals/delta |
budget.py |
Budget gate |
usage.py |
Planned usage file/flags |
periods.py |
hour/month/year scaling |
errors.py |
Structured errors + exit codes |
Extension point: register a new estimator in estimate.ESTIMATORS for additional nebius_* resource types.
Covered estimators include Compute instances/disks/snapshots/filesystems, Object Storage buckets, VPC allocations, Managed PostgreSQL, Managed MLflow, MK8s node groups, and Serverless AI endpoints. Free/control-plane types are listed in the catalog free_resource_types.
Refreshing prices
python scripts/refresh_catalog.py
python scripts/refresh_catalog.py --spot-snapshot # compare live public spot API to catalog floors
Edit data/prices.json (and mirror src/nebius_tf_cost/data/prices.json) from the published docs floors / fixed preemptible rows — do not invent rates for platforms absent from those tables. Re-run tests. Do not commit credentials — this tool never needs them (the spot snapshot API is public and unauthenticated).
Discovering new provider types
Weekly GitHub Actions workflow .github/workflows/discover-uncovered-types.yml (also workflow_dispatch) inventories Nebius Terraform provider resource types from the public provider docs tree (GitHub Contents API — no secrets), diffs them against estimate.ESTIMATORS and catalog free_resource_types, and opens or updates GitHub issues for newly uncovered types.
- Issue title convention:
feature: cover nebius_<type>(deduped by that title / type name among existing issues) - Label:
feature(created if missing) - Issues are coverage feature requests only — they do not invent prices
python scripts/discover_uncovered_types.py --dry-run --repo yacompsci/nebius-tf-cost-estimate
Min vs max
- min — optimistic (published spot floors / fixed preemptible rates; autoscaling
min_node_count) - max — pessimistic (on-demand ceiling for dynamic spot under
--preemptible-policy on_demand; autoscalingmax_node_count); budget uses this - Fixed preemptible platforms (L40S) use published preemptible list rates for both bounds
See ASSUMPTIONS.md for full semantics (including when instance
boot_disk / secondary_disks fold into the instance vs attach-by-ref).
Contributing
Contributions are welcome. See:
- CONTRIBUTING.md — setup, lint/test, PR norms, e2e, versioning / releases
- CHANGELOG.md — Keep a Changelog release notes
- AGENTS.md — layout and rules for coding agents
- CODE_OF_CONDUCT.md
- SECURITY.md — vulnerability reporting (no cloud secrets required to use or test this tool)
Licensed under the Apache License 2.0 (matches pyproject.toml).
Metadata
Release files for nebius-tf-cost 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nebius_tf_cost-1.0.0.tar.gz | 57.7 kB | With provenance | Details for nebius_tf_cost-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nebius_tf_cost-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for nebius_tf_cost-1.0.0-py3-none-any.whl |
Total release size: 102.0 kB
Release files / nebius_tf_cost-1.0.0.tar.gz
| Download URL | nebius_tf_cost-1.0.0.tar.gz |
|---|---|
| Size | 57.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0d37302691d76ebb4b0f43deee085d2b2fc572624ad17d674d57fa684598f77
|
|
BLAKE2b-256 checksum How to use checksums |
115ef64531bf4c7a379c451e0d7fd4cfe877eb4624515ff71455fb8c9c18d28e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logRelease files / nebius_tf_cost-1.0.0-py3-none-any.whl
| Download URL | nebius_tf_cost-1.0.0-py3-none-any.whl |
|---|---|
| Size | 44.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6cb4337a6cd370776eb77cc3a9d681f3d78df43608ecf9d914b0044b98a5bdce
|
|
BLAKE2b-256 checksum How to use checksums |
0d146a7a8180b9414b9937dea4541d1cefcc92af13d9e69156dc271e3e980977
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logSecurity for nebius-tf-cost 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for nebius_tf_cost-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.