Claude Code on Amazon Bedrock
Learn about configuring Claude Code through Amazon Bedrock, including setup, IAM configuration, and troubleshooting.
Prerequisites
Before configuring Claude Code with Bedrock, ensure you have:
- An AWS account with Bedrock access enabled
- Access to desired Claude models (e.g., Claude Sonnet 4) in Bedrock
- AWS CLI installed and configured (optional - only needed if you don’t have another mechanism for getting credentials)
- Appropriate IAM permissions
Setup
1. Enable model access
First, ensure you have access to the required Claude models in your AWS account:
- Navigate to the Amazon Bedrock console
- Go to Model access in the left navigation
- Request access to desired Claude models (e.g., Claude Sonnet 4)
- Wait for approval (usually instant for most regions)
2. Configure AWS credentials
Claude Code uses the default AWS SDK credential chain. Set up your credentials using one of these methods:
Option A: AWS CLI configuration
Option B: Environment variables (access key)
Option C: Environment variables (SSO profile)
Option D: Bedrock API keys
Bedrock API keys provide a simpler authentication method without needing full AWS credentials. Learn more about Bedrock API keys.
Advanced credential configuration
Claude Code supports two configuration settings for dynamic AWS credential management:
awsAuthRefresh
This setting specifies a command for foreground authentication operations where output is visible to the user. It is typically used for SSO browser flows.
Example:
awsCredentialExport
This setting specifies a command that outputs AWS credentials in JSON format to stdout. The output is not displayed to the user, but is used by Claude Code for subsequent Bedrock requests.
Required output format is JSON with the following properties:
Example:
These settings can be used to call scripts that invoke alternative identity systems.
3. Configure Claude Code
Set the following environment variables to enable Bedrock:
When enabling Bedrock for Claude Code, keep the following in mind:
AWS_REGION
is a required environment variable. Claude Code does not read from the.aws
config file for this setting.- When using Bedrock, the
/login
and/logout
commands are disabled since authentication is handled through AWS credentials. - You can use settings files for environment variables like
AWS_PROFILE
that you don’t want to leak to other processes. See Settings for more information.
4. Model configuration
Claude Code uses these default models for Bedrock:
Model type | Default value |
---|---|
Primary model | us.anthropic.claude-3-7-sonnet-20250219-v1:0 |
Small/fast model | us.anthropic.claude-3-5-haiku-20241022-v1:0 |
To customize models, use one of these methods:
Prompt caching may not be available in all regions
IAM configuration
Create an IAM policy with the required permissions for Claude Code:
For more restrictive permissions, you can limit the Resource to specific inference profile ARNs.
For details, see Bedrock IAM documentation.
We recommend creating a dedicated AWS account for Claude Code to simplify cost tracking and access control.
Troubleshooting
If you encounter region issues:
- Check model availability:
aws bedrock list-inference-profiles --region your-region
- Switch to a supported region:
export AWS_REGION=us-east-1
- Consider using inference profiles for cross-region access
If you receive an error “on-demand throughput isn’t supported”:
- Specify the model as an inference profile ID