Tokenomics at scale: Track and cap Amazon Bedrock spend per IAM principal with CUR 2.0 and AWS Budgets

AWS published a walkthrough on its Machine Learning Blog describing how to attribute and cap Amazon Bedrock spending per IAM principal using only native AWS billing features. The approach uses identity data Amazon Bedrock already records, cost allocation tags, Cost and Usage Reports (CUR) 2.0 or Cost Explorer, and AWS Budgets with budget actions. It is positioned as an alternative to the earlier custom enforcement loop built on IAM Identity Center, Athena over model invocation logs, and Lambda, which gives near-real-time control but leaves code the operator must maintain.
The pattern splits into three stages: attribute, report, enforce. Attribution comes free because Bedrock captures the calling IAM user or role on every inference request without any change to model calls. Reporting means activating those identities as cost allocation tags and then reading spend in Cost Explorer or querying a CUR 2.0 export. Enforcement means creating a budget scoped to Bedrock and filtered to one identity or tag value, then attaching an action that applies a Deny IAM policy when the threshold is crossed.
Tagging depends on how principals are organized. Where each person or application has its own role, principal tags attached to the role are sufficient; they are static and apply to every request. The post shows an example tagging a role named BedrockDeveloperRole-alice with keys user, team and CostCenter via the aws iam tag-role command. Where several people share one role or traffic flows through a gateway, principal tags cannot separate users, so session tags passed at role assumption time are used instead. When a session tag and a principal tag share a key, the session tag wins. The role's trust policy must allow sts:TagSession. Session tags can arrive through sts:AssumeRole with --tags, through the https://aws.amazon.com/tags claim in an OIDC ID token on AssumeRoleWithWebIdentity, or through PrincipalTag:* mappings in a SAML assertion. Up to 50 principal or session tags can be applied per IAM user or role.
Tags only reach billing data after activation. In the Billing and Cost Management console, filtering by type IAM principal and activating the keys is required. In an AWS Organization, activation happens in the management account; member accounts cannot do it independently. Two timings matter: a tag key appears for activation only after the principal has made at least one Bedrock call, and it can take up to 24 hours to appear and another 24 hours after activation before it populates billing data. Activation is not retroactive.
For detailed analysis, a CUR 2.0 Standard export must be created with the Include caller identity option, hourly granularity, and the Amazon Athena integration selected, which produces Parquet files and, the post stresses, delivers a setup script alongside the data. Running that script once creates the Glue Data Catalog table; the console flow does not create it automatically. An export created before identity attribution was enabled will not gain it retroactively. In the export, principal and session tags appear as columns prefixed iamPrincipal/ and resource tags as resourceTags/. AWS also publishes a sample query set at aws-samples/sample-cur-iam-principal-bedrock-tracking.
An example Athena query groups by tags['iamPrincipal/team'] and line_item_usage_type, filtering on product_servicecode in AmazonBedrock and AmazonBedrockService, because Bedrock spend can land under more than one service code. The table name is whatever the setup script chose. Two cautions accompany queries: Bedrock bills four token types (input, output, cache read, cache write) each at a different rate, so summing only input and output undercounts, especially with heavy prompt caching; and rates depend on token type, service tier and whether cross-Region inference was used, so the rate should be matched to each line item rather than applied per model.
Enforcement is a budget action rather than code. The relevant action type here is applying a custom IAM policy. The post's example Deny policy blocks bedrock:InvokeModel and bedrock:InvokeModelWithResponseStream on a named higher-cost model ID, leaving a cheaper model available so the user can keep working. Two distinct roles are involved: the operator configuring the budget needs the managed policy AWSBudgetsActionsWithAWSResourceControlAccess, which includes the conditioned iam:PassRole needed to hand the action role to Budgets; the role Budgets assumes to carry out the action has no single named managed policy for this case and must be built with a trust policy for budgets.amazonaws.com scoped by aws:SourceArn and aws:SourceAccount, plus permissions for iam:AttachRolePolicy and iam:DetachRolePolicy (and the organizations equivalents if SCPs are used). The budget is a cost budget on Bedrock filtered to the identity or tag, with an alert threshold set to Actual or Forecasted, the action pointed at the Deny policy and target principal, and automatic or human-approved execution chosen. Multiple actions per threshold and multiple thresholds per budget allow tiering, for example denying a premium model at 80 percent and a mid-tier one at 100 percent while never denying the cheap model. Only the management account can apply SCPs.
The approach has real limits. Budget data refreshes up to three times a day, so spend can overshoot before an action fires. CUR does not contain per-request line items; it aggregates by usage type, operation and attributes over an hour or day. IAM principal fields exist only in CUR 2.0. Session tags are fixed at AssumeRole time, surface only as aggregated billing data, and are not written to model invocation logs, which capture identity.arn; request-level distinction on a shared session needs a per-user RoleSessionName or request metadata. Budget actions attach to users, groups or roles, so a shared role means a Deny blocks everyone on it, and federated users without a standing IAM identity need a role to target. An LLM gateway collapses attribution to its own execution role by default. Because usage types are model-specific, newly enabled models should be checked in queries and budget filters.
Why it matters: teams running Bedrock across many developers now have a native path to per-person or per-team cost reporting and automated caps without owning an enforcement service, which lowers the barrier to expanding AI access with finance sign-off. The trade-off is precision and latency: budgeting is not near-real-time, and isolation only works where each person has a distinct role, so shared-role or gateway architectures still likely need the custom per-user approach. Product and platform teams should decide early whether per-user roles or session-tagged shared roles fit their identity model, since that choice determines whether a budget action can isolate one user.
Based on reporting from the original publisher. Visit the source for full context and later updates.
Publisher excerpt
Get per-identity Amazon Bedrock cost visibility and enforceable spend limits using only AWS-native features, with no application code for the common case. Attribute spend with IAM principal tags, report with CUR 2.0 or Cost Explorer, and enforce with AWS Budgets actions that apply a Deny policy when a threshold is crossed.