Skip to content

Amazon Bedrock Setup

Deploy Claude Code with AWS Bedrock for enterprise-grade AI capabilities with AWS integration.

Prerequisites

  • AWS account with Bedrock access enabled
  • Access to desired Claude models in Bedrock
  • AWS CLI installed and configured (optional)
  • Appropriate IAM permissions

Quick Setup

bash
# Enable Bedrock integration
export CLAUDE_CODE_USE_BEDROCK=1
export AWS_REGION=us-east-1

# Using AWS CLI credentials
aws configure

Step-by-Step Setup

Step 1: Submit Use Case Details

First-time Anthropic model users must complete this one-time process:

  1. Verify proper IAM permissions
  2. Navigate to Amazon Bedrock console
  3. Select Chat/Text playground
  4. Choose any Anthropic model and complete the use case form

Step 2: Configure AWS Credentials

Choose one authentication method:

Option A: AWS CLI

bash
aws configure

Option B: Environment Variables (Access Key)

bash
export AWS_ACCESS_KEY_ID=your-access-key-id
export AWS_SECRET_ACCESS_KEY=your-secret-access-key
export AWS_SESSION_TOKEN=your-session-token  # if using temporary credentials

Option C: AWS SSO Profile

bash
aws sso login --profile=your-profile-name
export AWS_PROFILE=your-profile-name

Option D: Bedrock API Keys

bash
export AWS_BEARER_TOKEN_BEDROCK=your-bedrock-api-key

Step 3: Enable Bedrock Integration

bash
export CLAUDE_CODE_USE_BEDROCK=1
export AWS_REGION=us-east-1  # or your preferred region

# Optional: Override region for small/fast model
export ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION=us-west-2

Important

AWS_REGION is required - Claude Code does not read from .aws config files.

Step 4: Configure Models

Default models:

TypeModel ID
Primaryglobal.anthropic.claude-sonnet-4-5-20250929-v1:0
Small/Fastus.anthropic.claude-haiku-4-5-20251001-v1:0

Custom models:

bash
# Using inference profile ID
export ANTHROPIC_MODEL='global.anthropic.claude-sonnet-4-5-20250929-v1:0'
export ANTHROPIC_SMALL_FAST_MODEL='us.anthropic.claude-haiku-4-5-20251001-v1:0'

# Using application inference profile ARN
export ANTHROPIC_MODEL='arn:aws:bedrock:us-east-2:your-account-id:application-inference-profile/your-model-id'

# Optional: Disable prompt caching
export DISABLE_PROMPT_CACHING=1

Step 5: Output Token Configuration

Recommended settings for Bedrock:

bash
export CLAUDE_CODE_MAX_OUTPUT_TOKENS=4096
export MAX_THINKING_TOKENS=1024

Reasoning:

  • 4096 tokens: Bedrock's minimum penalty threshold
  • 1024 thinking tokens: Balanced for coding tasks

IAM Configuration

Create an IAM policy with minimum required permissions:

json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowModelAndInferenceProfileAccess",
      "Effect": "Allow",
      "Action": [
        "bedrock:InvokeModel",
        "bedrock:InvokeModelWithResponseStream",
        "bedrock:ListInferenceProfiles"
      ],
      "Resource": [
        "arn:aws:bedrock:*:*:inference-profile/*",
        "arn:aws:bedrock:*:*:application-inference-profile/*",
        "arn:aws:bedrock:*:*:foundation-model/*"
      ]
    },
    {
      "Sid": "AllowMarketplaceSubscription",
      "Effect": "Allow",
      "Action": [
        "aws-marketplace:ViewSubscriptions",
        "aws-marketplace:Subscribe"
      ],
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "aws:CalledViaLast": "bedrock.amazonaws.com"
        }
      }
    }
  ]
}

Advanced: SSO Credential Refresh

For automatic credential refresh with AWS SSO:

json
{
  "awsAuthRefresh": "aws sso login --profile myprofile",
  "env": {
    "AWS_PROFILE": "myprofile"
  }
}

Troubleshooting

Region Issues

bash
# Check available models
aws bedrock list-inference-profiles --region your-region

# Switch to supported region
export AWS_REGION=us-east-1

On-Demand Throughput Error

Specify the model as an inference profile ID instead of model ARN.

API Support Note

Claude Code uses the Bedrock Invoke API (not Converse API).

Complete Configuration Example

bash
# ~/.bashrc or ~/.zshrc
export CLAUDE_CODE_USE_BEDROCK=1
export AWS_REGION=us-east-1
export AWS_PROFILE=my-bedrock-profile
export CLAUDE_CODE_MAX_OUTPUT_TOKENS=4096
export MAX_THINKING_TOKENS=1024
export ANTHROPIC_MODEL='global.anthropic.claude-sonnet-4-5-20250929-v1:0'

Next Steps

Claude Code Documentation Hub