LINESERVE
All tutorials
AI & ToolsAll levels

How to Use Claude Code with AWS Bedrock

Run Claude Code against Anthropic models on Amazon Bedrock by setting CLAUDE_CODE_USE_BEDROCK, configuring AWS credentials and IAM permissions, and choosing inference profiles.

Stephen NdegwaPublished Last updated 2 min read
Share

This guide shows how to run Claude Code using Anthropic models hosted on Amazon Bedrock, instead of Anthropic’s direct API.


Overview

Claude Code supports Amazon Bedrock as a backend. When enabled, it:

  • Uses AWS credentials instead of an Anthropic API key
  • Calls Bedrock’s InvokeModel / Inference Profiles
  • Works with Claude Sonnet, Haiku, etc. available in your AWS Region

Prerequisites

1. AWS Account with Bedrock Enabled

  • Ensure Amazon Bedrock is enabled in your AWS account
  • Enable Anthropic models in the Bedrock console

AWS Bedrock Console
https://console.aws.amazon.com/bedrock/

Important: The first time you use Anthropic models, AWS requires you to submit a use-case form in the Bedrock playground.


2. Install Claude Code

Follow the official Claude Code installation guide:

Claude Code Docs
https://docs.anthropic.com/en/docs/claude-code

Verify installation:

claude --version

3. AWS Credentials

Claude Code uses the standard AWS SDK credential chain.

Supported options:

  • aws configure (access keys)
  • AWS SSO
  • Environment variables
  • EC2 / ECS / EKS IAM roles

Example: AWS CLI credentials

aws configure

Example: AWS SSO

aws sso login --profile my-profile
export AWS_PROFILE=my-profile

AWS Credentials Documentation
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html


Enable Bedrock in Claude Code

Set the following environment variables before running Claude Code.

Required

export CLAUDE_CODE_USE_BEDROCK=1
export AWS_REGION=us-east-1

AWS_REGION must be set explicitly, even if your AWS config file has a default region.


Optional: Separate Region for Fast Model

export ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION=us-west-2

Choose Claude Models (Optional)

Claude Code provides defaults, but you can override them.

Example model overrides

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 an inference profile

You can also set an inference profile ARN:

export ANTHROPIC_MODEL="arn:aws:bedrock:us-east-1:123456789012:inference-profile/my-profile"

Bedrock Inference Profiles
https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles.html


Anthropic recommends these settings for Claude Code on Bedrock:

export CLAUDE_CODE_MAX_OUTPUT_TOKENS=4096
export MAX_THINKING_TOKENS=1024

To disable prompt caching:

export DISABLE_PROMPT_CACHING=1

Run Claude Code

Once everything is set:

claude

Authentication is handled entirely by AWS credentials.

/login and /logout commands are not used when running via Bedrock.


IAM Permissions

Your IAM user or role needs (at minimum):

{
 "Effect": "Allow",
 "Action": [
 "bedrock:InvokeModel",
 "bedrock:InvokeModelWithResponseStream",
 "bedrock:ListInferenceProfiles"
 ],
 "Resource": "*"
}

Bedrock IAM Permissions
https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam.html


Troubleshooting

List available models / inference profiles

aws bedrock list-inference-profiles --region us-east-1

Common issues

IssueFix
Model not foundUse a Region where the model is available
On-demand throughput errorUse an inference profile
Auth errorsVerify AWS credentials and IAM permissions
/login doesn’t workExpected when using Bedrock


Summary

Using Claude Code with AWS Bedrock lets you:

  • Avoid direct API keys
  • Centralize billing and security in AWS
  • Use IAM, SSO, and inference profiles

Once the environment variables are set, Claude Code works exactly the same—just backed by Bedrock.