How to Track AI Spending in Amazon Bedrock with IAM Cost Allocation

From 391043 Stack, the free encyclopedia of technology

Introduction

As teams rapidly adopt AI-driven development, cost visibility becomes a critical concern. Finance and leadership need to know who is using which AI resources and at what cost—especially when moving from experiments to production. Amazon Bedrock now supports cost allocation by IAM user and role, enabling you to tag IAM principals (like users or roles) with attributes such as team or cost center. Once activated in your Billing and Cost Management console, the resulting cost data flows into AWS Cost Explorer and the detailed Cost and Usage Report (CUR), giving you clear insight into model inference spending. Whether you’re scaling agents across teams, tracking foundation model usage by department, or running tools like Claude Code on Amazon Bedrock, this new feature is a game changer. Follow this step-by-step guide to set up cost allocation for Bedrock and take control of your AI investments.

How to Track AI Spending in Amazon Bedrock with IAM Cost Allocation
Source: aws.amazon.com

What You Need

  • An active AWS account with access to Amazon Bedrock.
  • IAM permissions to tag users and roles (iam:TagUser, iam:TagRole).
  • Access to the AWS Billing and Cost Management console (requires billing permissions).
  • Basic familiarity with IAM principals (users and roles).
  • A tagging strategy—decide which attributes (e.g., team, cost center, project) to use.

Step-by-Step Instructions

Step 1: Identify and Organize Your IAM Principals

First, list all IAM users and roles that interact with Amazon Bedrock. These might be developer roles, service roles for CI/CD pipelines, or IAM users running Claude Code. Group them logically by team, project, or cost center. You’ll apply tags to each principal to track Bedrock usage.

Step 2: Assign Tags to Your IAM Users and Roles

Go to the IAM console, select the user or role, and navigate to the Tags tab. Click Add tags and enter a key-value pair. For example:

  • Key: team, Value: engineering
  • Key: cost-center, Value: cc-123

Repeat for all IAM principals that will use Bedrock. You can also use AWS CLI or SDK: aws iam tag-user --user-name [username] --tags Key=team,Value=engineering.

Step 3: Enable User-Defined Cost Allocation Tags in Billing

Open the AWS Billing and Cost Management console, go to Cost Allocation Tags in the left menu. In the User-defined cost allocation tags section, click Activate next to the tags you created (e.g., team, cost-center). This triggers the system to start tracking costs by these tags.

Note: Activation can take up to 24 hours to fully propagate.

Step 4: Verify Tag Activation in Cost Explorer

After activation, navigate to AWS Cost Explorer. In the Filters pane, choose Tag and select your tag key. You should see the available values (e.g., engineering). If not, wait a few more hours and refresh.

To confirm Bedrock costs appear, apply a filter for Service = Amazon Bedrock and group by your tag key. This will show model inference costs per team or cost center.

How to Track AI Spending in Amazon Bedrock with IAM Cost Allocation
Source: aws.amazon.com

Step 5: Use Cost Explorer to Analyze Bedrock Spending

In Cost Explorer, create a new report. Set the Group by dimension to Tag and choose your tag key (e.g., team). Add a filter for Service = Amazon Bedrock. The chart will display Bedrock costs segmented by tag value. You can also save the report for recurring monitoring.

For a deeper dive, export the data to a CSV or use the Cost and Usage Report (CUR) with Athena or QuickSight.

Step 6: (Optional) Set Up Budgets and Alerts

To avoid surprises, create an AWS Budget that uses your cost allocation tags. Go to Budgets in Billing, click Create a budget, choose Cost budget, and set a name. Under Filters, add a tag filter (e.g., tag:team = engineering). Set a budget amount and threshold alerts. This way, teams get notified if their Bedrock usage exceeds planned spending.

Step 7: Scale and Maintain

As new users or roles are added, remember to tag them. Use AWS IAM Tag Policies or Service Control Policies (SCPs) to enforce tagging for IAM principals. You can also automate tagging via AWS Lambda or CloudFormation.

Periodically review your cost allocation reports to ensure tags are applied correctly and no costs are unassigned.

Tips for Success

  • Plan your tag taxonomy: Use consistent naming (e.g., cost-center, project) that aligns with your organization’s financial structure.
  • Combine with resource tags: For even granularity, tag your Bedrock model invocation resources (if supported). But remember, this feature tags IAM principals, not the models themselves.
  • Use CloudTrail to audit: Track who tags what to ensure compliance.
  • Monitor tag activation delays: Billing data may take up to 24 hours after activation.
  • Leverage AWS CUR: The Cost and Usage Report includes tag columns; query it with Athena for custom dashboards.
  • Protect your tags: Use IAM policies with conditions to enforce tagging on new IAM principals.

With this setup, you’ll gain full visibility into AI costs—empowering teams to innovate without financial surprises.