Skip to main content

Scan GCP billing accounts and bulk re-link their projects to a new account atomically, with dry-run, verification, CSV results, and an auto-generated rollback plan.

Project description

gcp-billing-radar

Atomically re-link GCP projects to a new billing account in bulk — with dry-run by default, per-project verification, CSV results, and an auto-generated rollback plan.

Each re-link is a single atomic API call (projects.updateBillingInfo): the project moves from the old billing account to the new one with no unbilled gap and no downtime. Mid-cycle usage is split between the two accounts by Google automatically.

Install

pip install gcp-billing-radar

Auth

Uses Application Default Credentials:

gcloud auth application-default login
# or GOOGLE_APPLICATION_CREDENTIALS=/path/to/sa-key.json

Required permissions:

  • resourcemanager.projects.updateBillingInfo on each project (Project Owner / Billing Project Manager)
  • billing.resourceAssociations.create on the target billing account (Billing Account User or Admin)

Usage

# 1. See what's on the old account
gcp-billing-radar list-projects -b OLD-ACCOUNT-ID --plain > projects.txt

# 2. Dry run (default — nothing is changed)
gcp-billing-radar swap -f projects.txt -b XXXXXX-XXXXXX-XXXXXX

# 3. Execute
gcp-billing-radar swap -f projects.txt -b XXXXXX-XXXXXX-XXXXXX --execute

# 4. Undo everything if needed
gcp-billing-radar rollback rollback-20260710-101500.csv

Projects can also be passed positionally or piped via stdin:

gcp-billing-radar list-projects -b OLD-ID --plain | \
  gcp-billing-radar swap -b NEW-ID --execute

Behavior

  • Dry-run by default — mutation requires an explicit --execute.
  • Idempotent — projects already on the target account are skipped; safe to re-run.
  • Per-project isolation — one failure (e.g. a 403) doesn't abort the batch.
  • Verification — after each link the project's billing info is re-read and compared.
  • Rollback plan — every successful swap is recorded with its original account in rollback-<ts>.csv, consumable by the rollback subcommand.
  • Results CSV — full audit trail (results-<ts>.csv) for every run, including dry runs.
  • Exit code is non-zero if any project failed — CI/pipeline friendly.

Output files

Every run writes two CSV files to the working directory:

results-<ts>.csv — full audit trail of every project in the run:

project_id,old_account,new_account,status,detail
project1,OLD111-AAAAAA-BBBBBB,XXXXXX-XXXXXX-XXXXXX,success,
project2,OLD111-AAAAAA-BBBBBB,XXXXXX-XXXXXX-XXXXXX,success,
already-done,XXXXXX-XXXXXX-XXXXXX,XXXXXX-XXXXXX-XXXXXX,skip-already-linked,

rollback-<ts>.csv — the undo plan, mapping each moved project back to its original account:

project_id,restore_to_account
project1,OLD111-AAAAAA-BBBBBB
project2,OLD111-AAAAAA-BBBBBB

Feed the rollback file straight back in to revert: gcp-billing-radar rollback rollback-<ts>.csv.

Python API

from gcp_billing_radar import BillingSwapper

s = BillingSwapper()
report = s.swap_batch(["proj-a", "proj-b"], "XXXXXX-XXXXXX-XXXXXX", execute=True)
print(len(report.success), "moved")
report.write_rollback()

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gcp_billing_radar-0.1.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gcp_billing_radar-0.1.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file gcp_billing_radar-0.1.1.tar.gz.

File metadata

  • Download URL: gcp_billing_radar-0.1.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for gcp_billing_radar-0.1.1.tar.gz
Algorithm Hash digest
SHA256 03af140d6e5391c9f509ff460a7e267e54a1e4afa2b114330dd26b2ea1b63579
MD5 58efab27a01ecc335a725fecf6a22ace
BLAKE2b-256 653404dabda73e135b5beead8fe58e127390e7b1e8ba099dddfaf5c23ca7a8ca

See more details on using hashes here.

File details

Details for the file gcp_billing_radar-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gcp_billing_radar-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 823ba0144da0a4408b90d9ca95a46fc8acdc484143c10f2cf4fa2b97364dd20b
MD5 ff18a631076c76e069e2a119ccd03dc3
BLAKE2b-256 3cead3bed9e7d619f5ed839ffeec001ce0eb18bc0128279cf01db2d082ad8613

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page