Google Cloud Spend Cap Kit (Python)
Leaked API keys and runaway services keep producing five-figure Google Cloud bills. In late 2026 Google made native spend caps generally available. Budget alerts only warn you. A spend cap actually pauses new usage once spend passes your limit.
Spend caps are fiddly to set up:
- Each cap covers only one project and one service.
- Only 4 services are eligible: Gemini API, Vertex AI, Cloud Run and Cloud Run functions.
- The fields have to be set exactly right.
- There is no gcloud flag for them.
- Everything else (Maps, BigQuery, Compute, unrestricted API keys) is still unprotected.
This kit shows where you are exposed and sets the caps up correctly:
- capguard.py audit (read-only) checks every project you can see. It flags:
- eligible services with no spend cap
- caps that are currently enforced
- billable services that caps can't cover and that have no alert budget
- unrestricted API keys, and keys allowed to call Gemini or Vertex AI
- Cloud Run services with no max-instances limit (the default is 100)
- capguard.py plan --amount 40 writes the exact request for each missing cap. Nothing is sent.
- capguard.py apply plan.json re-checks what already exists, asks for confirmation, then creates only the missing caps.
- lift and keys commands, a RUNBOOK for the first hour of a bill spike, and a CHECKLIST for new projects.
- 16 tests, standard library only, and it uses your own gcloud login.
Honest limits:
- Caps cover only 4 services today.
- Caps use estimated costs, so some overspend is still possible.
- Alert budgets never stop spending.
- No organisation- or folder-wide caps.
- Built from Google's docs as of 4 December 2026.
- This kit can't promise refunds for past bills.
- Not affiliated with Google.
MIT licensed. Instant download. By Saggurthi Labs.