What is Spend as Code?
Your cloud and AI spend rules in one file, checked everywhere money is spent.
Coming soon Spend as Code is a solution we are building. This page explains the idea. It is not for sale yet.
In 30 seconds
Spend as Code puts the rules for cloud and AI spend in one file in your repo.
- Budgets, allowed instance types, allowed models and token limits, side by side.
- Changes to the rules are reviewed like code.
- The same file is checked wherever money is spent.
Why savings creep back
New services launch on default sizes and new features call the largest model. The rules that would stop it exist, but scattered: a spreadsheet, a wiki, a console. Nothing checks a change against them.
A saving made in March can be gone by June, one default at a time. A budget alert in the cloud console speaks after the money is spent. A rule checked in review stops the change before it ships, while fixing it is still one pull request.
One file, three checks
In review
A change that would break a budget or use a model outside the list fails its check before it ships.
In the cloud account
The budget alerts the owner before the month runs over.
In the AI gateway
Each route gets its allowed model and its token limit.
For engineers: what the file could look like
team: checkout
monthly_budget_usd: 4000
cloud:
instance_families: [m7g, c7g]
max_on_demand_share: 0.3
ai:
routes:
support-summary: {model: small, max_output_tokens: 400}
contract-review: {model: large, monthly_cap_usd: 800}
Illustrative. Exceptions are pull requests too: more budget is a reviewed change, not a message in a chat.
What goes in the file
- Budgets per team or service, a month, in dollars.
- Allowed instance families, and how much may run On-Demand.
- Allowed models per AI route, with a token limit or a monthly cost cap.
- Owners: who approves a change to each part.
The rules sit in the repo next to the code they govern, so a reviewer sees the rule and the change in the same place, and the history shows who changed a budget and why.
Budget alerts and rules in review
| Budget alert | Spend as Code | |
|---|---|---|
| When it acts | When costs approach or pass a threshold | Before the change ships, in review |
| Who sees it | The account owner | The team making the change |
| What it covers | One account or service | Cloud and AI, in one file |
| How it changes | In the console | With a pull request, reviewed like code |
AWS Budgets lets you receive alerts when costs approach or exceed a threshold you set (AWS, checked November 8, 2026). Spend as Code keeps that alert and adds the check before the change.
Questions
Would a failed check block every deploy? No. The idea is that it blocks only the change that breaks a rule, with the reason in the check. A team that needs more budget asks for it with a pull request to the file, approved by whoever owns the budget.
Who owns the file? Each team owns its part of the file. The people who approve spend approve the changes to it, like any other code owner in the repo.
Can we start without it? Yes. Savings as Code works on its own today. The rules can start as a short file that only describes today's budgets, and grow when a team asks for a check.
Does it replace a cost dashboard? No. A dashboard shows where the money went. Spend as Code is where the rules live, so the next change follows them.
Where it fits
Savings as Code removes the waste with changes you approve. Spend as Code keeps it from coming back: each saving can be protected by a rule. Spend as Code is coming soon; the way in today is Savings as Code.