A Brake and a Kill Switch for Runaway Amazon Bedrock Spend
DEV Community

A Brake and a Kill Switch for Runaway Amazon Bedrock Spend

Picture this: an AI agent in your account gets stuck in a loop because of a small bug. One request to an agent can already trigger ten model calls - a loop can trigger hundreds.

With classic AWS budgets, you find out the next morning in Cost Explorer. The damage is visible, but nothing stopped it.

Since December 1, 2026, AWS offers a built-in answer: AI cost governance in Billing and Cost Management. I tested it and wrote up a full guide to capping Amazon Bedrock costs with AI budgets. This post gives you the essentials.

Why classic budgets are too slow for AI

Classic budgets run on billing data. AWS itself notes that they refresh up to three times a day and that Bedrock costs can take up to a day to appear. That is fine for EC2, which costs roughly the same every hour. It is not fine for AI workloads, where an agent can burn a week's budget in an hour.

The new launch has two parts, both free and available in all commercial Regions except GovCloud and China:

  • An AI cost dashboard that shows Bedrock token spend, Kiro credits and AWS Quick agent hours within minutes, broken down by account, Region, model and IAM principal. Note that it calculates costs itself from token counts, so numbers can differ from your bill, and fixed costs like Provisioned Throughput are not included.
  • AI budgets per day, week or month for accounts, and - in preview - for IAM Identity Center users, groups and IAM principals.

One detail matters a lot for automation: email alerts arrive as a daily digest at 9:00 UTC, while an SNS topic receives each alert immediately. If you want to react automatically, SNS is the only real option.

My pattern: a brake and a kill switch

I suggest two stages rather than one. The brake lives inside your application. An AI budget on the Lambda execution role sends an SNS alert at 80%. A small watcher function flips a flag in SSM Parameter Store from "normal" to "economy", and the app switches to a smaller, cheaper model. The next alert moves it to "off", where users get static answers instead of AI. Users still get a response - just a simpler one.

The kill switch is an account-level AI budget in the management account of your organization. At 100%, AWS Budgets updates a managed service control policy that denies new Bedrock calls such as bedrock:InvokeModel* in the selected accounts. It is deliberately blunt and should only fire when the brake fails or someone outside the app is spending.

I keep a clear gap between the two - in my example 40 USD per day for the app versus around 100 USD for the account.

Because SNS delivers at least once, the watcher must be idempotent. The core logic is tiny and testable without AWS:

export type AiMode = 'normal' | 'economy' | 'off';

export function nextMode(mode: AiMode): AiMode {
  if (mode === 'normal') return 'economy';
  return 'off';
}

// Ignore duplicate SNS deliveries
export function handleAlert(state, messageId) {
  if (state.lastMessageId === messageId) return state;
  return { mode: nextMode(state.mode), lastMessageId: messageId };
}

A scheduled function resets the mode shortly after the budget period starts again at 00:00 UTC.

The limits you should know

The kill switch comes with conditions that are easy to overlook:

  • Blocking only works from the management account - and never for the management account itself, since SCPs do not apply there. Keep AI workloads in dedicated workload accounts.
  • Once you filter by model, provider or Region, blocking is no longer available.
  • Only new calls are blocked; running batch jobs and Provisioned Throughput keep going.
  • Budgets per person, group or IAM principal only alert, they do not block.
  • If several apps share one execution role, the budget counts them together. One role per function is good practice anyway.

As a team lead, I also see a cultural risk: budgets per person can quickly turn into a leaderboard. I would start with one shared pool per team and, when a budget is exceeded, ask "what caused this?" rather than "who did this?". Often it is a loop in an agent, not a person.

What the full article covers

  • Step-by-step console setup for the kill switch and the identity budget
  • The complete Lambda code for the watcher, the model switch and the daily reset
  • A ready-to-deploy serverless.yml with SNS topic policy and Bedrock permissions
  • Tests, a cost-free way to verify the wiring, and common setup mistakes
  • An FAQ plus a link to the runnable example repository

Read the full article here: Cap Amazon Bedrock Costs with AWS AI Budgets 📖

This is the condensed version. The full article on sascha-ms.de goes deeper - with all code samples, diagrams and a short knowledge check.

👉 Next step: Not sure which AWS service fits your use case? My AWS service finder asks a few questions and points you to the right one.

📬 Stay updated: New articles on serverless, AI and leading tech teams via RSS, browser push or the weekly newsletter (in German).

Originally published on sascha-ms.de. More articles on serverless, AI in everyday development and leading tech teams: sascha-ms.de/en

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.