AWS lays out an end-to-end Bedrock cost playbook: spend attributed to each IAM principal, over-budget users blocked in seconds to minutes, and more than half of coding-fleet calls on cheaper models
A checklist in five stages, attribution, observability, enforcement, optimization and governance, aimed at platform teams rolling out coding agents.
// Key points
- Bedrock inference costs are attributed to the calling IAM principal in CUR 2.0, in the line_item_iam_principal column; activated principal tags show up in Cost Explorer within 24–48 hours.
- Behind a gateway, call STS AssumeRole once per user with attributes as session tags and cache credentials for up to an hour, one STS call per user per hour rather than per request.
- Enforcement comes in three tiers: AWS Budgets alerts only; a Lambda function with DynamoDB counters adds over-budget users to a shared IAM deny policy within seconds to minutes; a gateway returns HTTP 429 synchronously, with the Claude apps gateway or LiteLLM as options.
- CUR lags about 24 hours, so near-real-time spend needs CloudWatch plus OpenTelemetry; for agentic coding fleets the stated target is more than half of calls on cheaper models.
Builder's takeStart with the cheapest step: put requestMetadata (application, workflow, tenant) on every call, because attribution cannot be added after the fact. For multi-tenant products like AI Cloud Drive and AI Interview I would tag by tenant, add a hard 429 limit at the gateway, and cover the one-day billing lag with real-time logs. Read alongside today's Claude Code pooled budgets, knowing who spent what and how to stop overspend is now a prerequisite for rolling out agents.
// Background · from #Coding agents
Full timeline →- Nov 1 Claude Code 2.1.316 retires fast mode on Opus 4.8 on November 30, adds pooled group budgets to its gateway and a separate effort setting for subagents
- Nov 1 Bedrock AgentCore Runtime adds session endpoints: preview a web app in your own browser while a coding agent edits it in the cloud
- Oct 31 Claude Code 2.1.314 adds a setting that blocks writes outside the working directories in every permission mode