How to Attribute Bedrock Spend to Every IAM Role's Owner

How to Attribute Bedrock Spend to Every IAM Role's Owner

Cloud Platform Engineering

AWS has been able to charge Bedrock inference to an IAM user or role since April, so Cost Explorer can show that a role called research-agent-2 ran up the month’s biggest AI line, but not who research-agent-2 belongs to, writes Zeen Rachidi in The New Stack. For platform and FinOps teams running agents on shared roles, an untagged role is a corporate card with no manager, and the bill arrives before anyone can answer for it.

The Framework

The piece argues that budgets can’t be forecast for agents. It cites a study of frontier models on SWE-bench Verified in which repeated runs of the same task differed by as much as 30x in tokens, and in which models underestimated their own usage. If neither the task nor the model can say what a run will cost, attribution after the fact is the control left. The method has three parts: find spend with no owner, block new roles that arrive without one, and start the attribution clock early.

Step 1: Find the Roles With Spend and No Owner

Bedrock spend carries the caller’s identity only if you ask for it. In Data Exports, create a CUR 2.0 export with “Include caller identity (IAM principal) allocation data” selected. Existing exports don’t gain the column, so this is a new export. Principal tags arrive with an iamPrincipal/ prefix, and the article’s Athena query, adapted from AWS’s cost attribution examples, lists every role or user with Bedrock spend this month whose owner tag is missing or isn’t an email address. A team name or agent name fails the same test as a blank. Rows with no caller identity are left out and deserve a count of their own. Attribution covers model inference only; compute, storage and tool costs bill as before.

Once owner is an active cost allocation tag, AWS Budgets can filter on it, so each owner gets an alert when their roles cross a threshold.

Step 2: Block New Roles Without a Manager

The query finds roles that already exist. To stop new ones arriving anonymously, the article uses OPA/Rego rules over Terraform plan JSON, enforced as an env zero approval policy. Every IAM role or user must carry an owner tag holding a person’s email, and no policy may grant Bedrock or AgentCore actions on every resource. Policies unknown until apply or not valid JSON are denied too. The same rules run in conftest or any CI step, but a CI check only runs if the pipeline runs it.

The author lists the blind spots: managed policies attached by ARN are never inspected, NotAction and conditions aren’t evaluated, and roles created in the console or another pipeline skip the check. A role shared by several agents still attributes spend only to the role. For those, AWS supports a distinct RoleSessionName or session tags, with sts:TagSession allowed in the trust policy.

Step 3: Start the Clock, Then Plan the Exit

Attribution doesn’t backfill. Tags appear for activation only after a principal has made at least one Bedrock call, and AWS says keys can take up to 24 hours to appear and another 24 to activate. Cost allocation tags aren’t retroactive, and activation happens in the management account or a standalone one, not a member account. The order: tag known roles, activate owner, create the export, set a budget per owner, and run the query after a day and then monthly. Put temporary agent roles in an environment with a TTL so they leave when the work does.

Where It Doesn’t Apply

env zero sponsored the article, and its enforcement step is the vendor’s product, though the Rego runs free in conftest. Per-owner tags also don’t replace the shared-model split that Bedrock application inference profiles give by department.

The So What

If you own AWS spend for teams running agents, turn on caller identity in a new CUR 2.0 export and activate an owner cost allocation tag this week, because every week before activation is spend that never gets a name; then add the owner-tag rule to your Terraform plan checks so no new agent role ships without a person attached.

Source: The New Stack

Content created with AI assistance and reviewed for accuracy.

💬

Join the conversation

Stack Insiders is our free community for readers who want to go deeper — share resources, ask questions, and connect with others across every vertical we cover.

Join Stack Insiders →

Newsletter coming soon.

Curated digests across AI, biohacking, photography, travel, and more. Be the first to know when we launch.