Originally published on Build With AWS. Subscribe for weekly AWS builds.
Over the past few weeks, Claude Code has gained a lot of attention as a developer tool in the AI space.
With rapid improvements in its capabilities, better context handling, and an increasingly robust feature set, developers are flocking to this powerful CLI tool that brings Claude’s intelligence directly into their terminal workflow.
Whether you’re debugging complex codebases, refactoring legacy systems, or building new features, Claude Code has proven itself as an indispensable coding companion. But with great power comes great responsibility, and potentially significant API costs.
Why Route Claude Code Through AWS Bedrock?
If you’re already using Claude Code, you might be consuming the Anthropic API directly.
While this works perfectly fine, there are compelling reasons to route your Claude Code traffic through AWS Bedrock instead:
1. Cost Control and Transparency
AWS Bedrock provides granular billing through AWS Cost Explorer.
You can track AI spending alongside your other AWS services, set up billing alerts and budgets, and analyze usage patterns with detailed metrics.
This visibility enables better cost management compared to direct API billing.
AWS enterprise customers can also take advantage of committed use pricing and volume discounts that apply across their entire AWS footprint, potentially reducing AI infrastructure costs significantly.
2. Security and Compliance
For enterprises and security-conscious teams, Bedrock offers substantial advantages. Requests are made to Bedrock under your AWS account with IAM governance, CloudTrail auditing, and optional PrivateLink connectivity.
This provides complete visibility into who invoked which models and when, helping meet compliance requirements that mandate audit trails and access controls.
Every API call gets logged through CloudTrail, and you can leverage AWS IAM for fine-grained access control.
Organizations can also use AWS PrivateLink to keep API traffic off the public internet, simplifying governance and network security posture.
3. Observability
Bedrock integration provides comprehensive observability through CloudWatch metrics that track invocation counts, latency, and errors.
CloudTrail logs capture complete audit trails of every model invocation.
You can integrate these logs with your existing AWS monitoring stack, whether that’s CloudWatch dashboards, third-party tools, or custom alerting systems.
This allows you to set up alerts on usage patterns, detect anomalies, and troubleshoot issues using the same tools you already use for your AWS infrastructure.
4. Unified Cloud Strategy
Organizations already running infrastructure on AWS gain additional benefits from using Bedrock. Centralized billing consolidates AI costs with compute, storage, and other services, simplifying cost allocation and budgeting.
You get a single pane of glass for all cloud services rather than managing multiple vendor relationships.
This simplifies vendor management and allows you to leverage existing AWS support contracts and enterprise agreements for your AI infrastructure as well.
The Configuration Process
The good news?
Configuring Claude Code to use Bedrock is remarkably straightforward.
The changes are global, affecting all your projects and sessions once configured.
Prerequisites
Before you begin, ensure you have:
AWS CLI installed and configured with valid credentials
Claude Code CLI installed (recent version recommended)
AWS Bedrock model access enabled in your target region via the Bedrock console (some models require approval depending on region and account type)
Appropriate IAM permissions for bedrock:InvokeModel, bedrock:InvokeModelWithResponseStream, and bedrock:ListInferenceProfiles
Step 1: Verify AWS Credentials
First, confirm your AWS CLI is properly configured:
aws sts get-caller-identity
You should see output like:
"UserId": "AIDAXXXXXXXXXXXXXXXXX",
"Account": "123456789012",
"Arn": "arn:aws:iam::123456789012:user/your-username"
Step 2: Set Environment Variables
The configuration happens through environment variables.
Add these to your shell configuration file (~/.zshrc, ~/.bashrc, or ~/.bash_profile):
# Enable Bedrock for Claude Code
export CLAUDE_CODE_USE_BEDROCK=1
# Set your preferred AWS region (REQUIRED - Claude Code does not read from ~/.aws/config)
export AWS_REGION=us-east-1
After adding these lines, reload your shell configuration:
source ~/.zshrc # or ~/.bashrc
Step 3: Verify the Configuration
Check that the environment variables are set:
env | grep -E "CLAUDE_CODE_USE_BEDROCK|AWS_REGION"
Expected output:
CLAUDE_CODE_USE_BEDROCK=1
AWS_REGION=us-east-1
That’s it! No per-project configuration needed.
These environment variables tell Claude Code to route all LLM requests through AWS Bedroc
Tags:
#0
Want to run a more efficient business?
Mewayz gives you CRM, HR, Accounting, Projects & eCommerce — all in one workspace. 14-day free trial, no credit card needed.
Try Mewayz Free →