Per-user cost attribution for AI tools on Amazon Bedrock
As AI coding and productivity tools spread across a company, finance and platform teams face a basic question they cannot answer: which person and which team is actually generating the Bedrock bill? The usual setup makes this hard. Tools like Claude Code, Claude Desktop, Codex and ChatGPT Work run on each user's machine and call Bedrock through a shared IAM role, so billing collapses every call into one principal and per-user spend disappears.
As AI coding and productivity tools spread across a company, finance and platform teams face a basic question they cannot answer: which person and which team is actually generating the Bedrock bill? The usual setup makes this hard. Tools like Claude Code, Claude Desktop, Codex and ChatGPT Work run on each user's machine and call Bedrock through a shared IAM role, so billing collapses every call into one principal and per-user spend disappears.
The author's point is that Bedrock already records who made each inference call, so no instrumentation is needed in the tools themselves. When a user invokes a model through the bedrock-runtime or bedrock-mantle endpoint, Bedrock captures the caller's full IAM ARN, including the session name, and publishes it to CUR 2.0 (the detailed AWS billing export) in a column called line_item_iam_principal. The trick is making that session name unique per person: with IAM Identity Center, the session name is the user's sign-in name, and organizational attributes such as team and cost center can be passed as session tags that appear in billing with an iamPrincipal/ prefix. Setup is a one-time chain: connect the external identity provider (Okta, Entra ID, Ping) to Identity Center, map attributes to session tags, create a Bedrock permission set, and have users run aws sso login once. Each tool then needs only a standard config change — an SSO profile for Claude Code, managed preferences for Claude Desktop, a config file for Codex — and attribution follows automatically. One trap the author flags: if AWS_BEARER_TOKEN_BEDROCK is set, tools authenticate with that key instead, and calls get attributed to the key's IAM user rather than the person. Billing data is aggregated per principal per export interval (hourly or daily), not per request; per-prompt detail requires invocation logs or request metadata tagging. For enforcement, the author compares options by latency: AWS Budgets is simplest but updates a few times a day and billing can lag up to 24 hours; CloudWatch alarms with Lambda react in 1–5 minutes but need per-user roles or inference profiles for user-level granularity; DynamoDB quota tracking blocks at credential refresh; an LLM gateway blocks per call at the highest operational cost. Most teams layer reporting, real-time control and a budget backstop.
If your developers reach Bedrock through shared credentials, you are probably flying blind on AI spend; moving them onto Identity Center SSO buys per-user attribution with no changes to the tools. Treat reporting and enforcement as separate layers, and pick your control mechanism by how much overshoot you can tolerate.