Run Claude Code CLI on Amazon Bedrock
Configure Claude Code CLI and Claude Code extension for VS Code on Amazon Bedrock with AWS profile
Overview
Claude Code is an AI-powered, terminal-native coding agent by Anthropic for developers. This article covers how to configure Claude Code CLI to use Anthropic Claude models on Amazon Bedrock
This article is for Code CLI. Similar articles are available for Claude Desktop and ChatGPT/Codex
Requirements
You will need the following
- Amazon Bedrock access to Anthropic Claude models
- AWS CLI installed and configured
- IAM permission access to Bedrock
Bedrock model access
Request Bedrock model access by selecting and interacting with an Anthropic model from the model catalog in the Amazon Bedrock console playground in your desired AWS Region. For Anthropic models, you must complete the First Time Use (FTU) form before invoking the model.
Create a support case if you are unable to use any models.
Data Retention
Data retention may be required for Claude Fable models before they can be used. To configure account-wide data retention mode for a specific Region, e.g. us-east-1, run the following command
aws bedrock put-account-data-retention --mode aws_review --region us-east-1
Refer to Amazon Bedrock abuse detection and AWS Service Terms for details.
IAM permission / IAM Identity Center permission set
Your AWS profile must have the following permissions
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"bedrock:InvokeModel",
"bedrock:InvokeModelWithResponseStream",
"bedrock:ListInferenceProfiles",
"bedrock:GetInferenceProfiles"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Condition": {
"StringEquals": {
"aws:CalledViaLast": "bedrock.amazonaws.com"
}
},
"Action": [
"aws-marketplace:Subscribe",
"aws-marketplace:ViewSubscriptions"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
If you are using IAM Identity Center (IdC), create a permission set with the above as inline policy. Assign your user or group access to your AWS account with the created permission set.
Install AWS CLI
Installation files
To install, you can download latest binaries/installer
- Windows : https://awscli.amazonaws.com/AWSCLIV2.msi
- Mac OS: https://awscli.amazonaws.com/AWSCLIV2.pkg
- Linux: https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip
Do refer to AWS CLI documentation for guidance and other installation options.
To verify
aws --version
Output should be similar to below
aws-cli/2.35.20 Python/3.14.6 Windows/11 exe/AMD64
Configure AWS CLI profile
You need to configure AWS credentials on your local machine. The server uses these credentials to authenticate your requests.
Do secure your AWS credentials as credential theft can lead to LLMJacking attacks
Option 1: AWS Management Console credentials
If you have username and password that allows you to sign in to the console.
aws login
Option 2: AWS SSO (IAM Identity Center)
If you login using organization instance of IAM Identity Center
aws configure sso
Follow the prompts to set up as per your Identity Center configuration
SSO session name (Recommended): BedrockInference
SSO start URL [None]: https://d-12345678.awsapps.com/start
SSO region [None]: ap-southeast-1
SSO registration scopes [sso:account:access]:
Attempting to open your default browser. If the browser does not open, open the following URL.
If you are unable to open the URL on this device, run this command again with the '--use-device-code' option.
Option 3: IAM User
If you have a IAM user
aws configure
Enter your Access Key ID, Secret Access Key, default region, and output format.
Option 4: EC2 Instance
On EC2 instances with no AWS profiles configured, AWS CLI automatically and securely retrieves the credentials from the instance metadata without additional configuration.
If you wish to configure a profile, for example EC2, that uses EC2 instance metadata
aws configure set --profile EC2 credential_source Ec2InstanceMetadata
aws configure set --profile EC2 region ap-southeast-1
Do replace ap-southeast-1 with the correct Region Code
Verify AWS profile
Do note the profile name. If you do not specify one, the profile name is usually default. You can retrieve profile name with the following command
List Profiles
aws configure list-profiles
Output could be similar to below
default
BedrockInference
/aws/config file
Or you can view contents of ~/.aws/config file. Example below is a AWS SSO configured profile with name BedrockInference
[profile BedrockInference]
sso_session = BedrockInference
sso_account_id = 123456789012
sso_role_name = BedrockInference
region = ap-southeast-1
[sso-session BedrockInference]
sso_start_url = https://d-12345678.awsapps.com/start
sso_region = ap-southeast-1
sso_registration_scopes = sso:account:access
Verify Bedrock Access
Run the following command (using correct AWS profile) to verify access to Bedrock models
aws bedrock list-inference-profiles --profile BedrockInference
IAM Identity Center login
For IdC, you may have to login first
aws sso login --profile BedrockInference
Install Claude Code CLI
Download and install Claude Code CLI as per Claude Code Docs
Windows PowerShell:
irm https://claude.ai/install.ps1 | iex
macOS, Linux, WSL
curl -fsSL https://claude.ai/install.sh | bash
Windows output
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\Windows\system32> irm https://claude.ai/install.ps1 | iex
Setting up Claude Code...
√ Claude Code successfully installed!
Version: 2.1.283
Location: C:\Users\Administrator\.local\bin\claude.exe
Next: Run claude --help to get started
‼ Setup notes:
● Native installation exists but C:\Users\Administrator\.local\bin is not in your PATH. Add it by opening: System
Properties → Environment Variables → Edit User PATH → New → Add the path above. Then restart your terminal.
✅ Installation complete!
PS C:\Windows\system32>
Add claude binary to your environment PATH
Setup Claude Code CLI with Bedrock
Start Claude
Run Claude Code CLI from terminal
claude
First setup
If this is first setup, select 3rd-party platform · Amazon Bedrock, Microsoft Foundry, or Vertex AI as login method
░░░░░░░░░░░░░░░░░░░ * ██▓░░ ▓
Welcome to Claude Code v2.1.283
..........................................................
* █████▓▓░
* ███▓░ ░░
░░░░░░ ███▓░
░░░ ░░░░░░░░░░ ███▓░
░░░░░░░░░░░░░░░░░░░ * ██▓░░ ▓
░▓▓███▓▓░
* ░░░░
░░░░░░░░
░░░░░░░░░░░░░░░░
█████████ *
██▄█████▄██ *
█████████ *
.......█ █ █ █..........................................
Claude Code can be used with your Claude subscription or billed based on API usage through your Console account.
Select login method:
1. Claude account with subscription · Pro, Max, Team, or Enterprise
2. Anthropic Console account · API usage billing
❯ 3. 3rd-party platform · Amazon Bedrock, Microsoft Foundry, or Vertex AI
Then select 1. Amazon Bedrock · interactive setup
Welcome to Claude Code v2.1.283
..........................................................
* █████▓▓░
* ███▓░ ░░
░░░░░░ ███▓░
░░░ ░░░░░░░░░░ ███▓░
░░░░░░░░░░░░░░░░░░░ * ██▓░░ ▓
░▓▓███▓▓░
* ░░░░
░░░░░░░░
░░░░░░░░░░░░░░░░
█████████ *
██▄█████▄██ *
█████████ *
.......█ █ █ █..........................................
Using 3rd-party platforms
❯ 1. Amazon Bedrock · interactive setup
2. Microsoft Foundry · opens docs
3. Google Vertex AI · interactive setup
4. Go back
Reconfigure
For existing Claude Code CLI install, use /setup-bedrock to start Bedrock interactive setup wizard
...
/setup-bedrock Reconfigure Amazon Bedrock authentication,
region, or model pins
/terminal-setup Check terminal setup (Shift+Enter is natively
supported in Windows Terminal)
──────────────────────────────────────────────────────────────────────────────────────
❯ /setup
──────────────────────────────────────────────────────────────────────────────────────
Configure Bedrock
Select AWS profile
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Set up Amazon Bedrock
How do you authenticate to AWS?
Claude Code uses the standard AWS credential chain. Pick the method you already use with the AWS CLI.
❯ 1. AWS profile (SSO or named profile)
2. Bedrock API key (bearer token)
3. Access key + secret
4. Use credentials already in my environment
↑/↓ to navigate · Enter to select · Esc to cancel
Select the AWS profile you have configured (To configure using other methods listed above, refer to Claude Code Docs)
``
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Set up Amazon Bedrock
AWS profile
Found 1 profiles in ~/.aws/config and ~/.aws/credentials.
❯ 1. BedrockInference
2. Type a different name…
↑/↓ to navigate · Enter to select · Esc to go back
Enter your Bedrock AWS Region
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Set up Amazon Bedrock
AWS region
Where your Bedrock models are enabled.
Claude Code reads this from AWS_REGION, not ~/.aws/config — set it explicitly even if your profile has a region.
ap-southeast-1
Enter to continue · Esc to go back
If your profile is configure correctly, Claude Code will login and retrieve Bedrock inference profiles
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Set up Amazon Bedrock
Verification
✔ Authenticated as arn:aws:sts::123456789012:assumed-role/AWSReservedSSO_BedrockInference_3ec244f92f7499f7/limmike
Found 17 Anthropic inference profiles in this region.
❯ 1. Continue
↑/↓ to navigate · Enter to select · Esc to go back
Claude will select default Sonnet, Opus, Haiku and Fable models. You can pin model versions, or skip
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Set up Amazon Bedrock
Pin model versions
Without pinning, Claude Code uses its built-in defaults. When a new model ships, your install will try to call it
even if your account has not yet enabled it — Claude Code will fail to connect to Bedrock until you enable the
model or pin to one you have.
Each candidate is tested with a one-token request:
✔ Sonnet → global.anthropic.claude-sonnet-5
✔ Opus → global.anthropic.claude-opus-5-5
✔ Haiku → global.anthropic.claude-haiku-5-5
✔ Fable → global.anthropic.claude-fable-5-1
❯ 1. Pin the working models
2. Pin the working models with 1M context
3. Choose different models…
4. Skip — use Claude Code defaults (auto-updates)
↑/↓ to navigate · Enter to select · Esc to go back
Select Save to save configuration to ~\.claude\settings.json file
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Set up Amazon Bedrock
Confirm and save
These will be written to ~\.claude\settings.json under env:
CLAUDE_CODE_USE_BEDROCK = 1
AWS_REGION = ap-southeast-1
AWS_PROFILE = BedrockInference
ANTHROPIC_DEFAULT_SONNET_MODEL = global.anthropic.claude-sonnet-5
ANTHROPIC_DEFAULT_OPUS_MODEL = global.anthropic.claude-opus-5-5
ANTHROPIC_DEFAULT_HAIKU_MODEL = global.anthropic.claude-haiku-5-5
ANTHROPIC_DEFAULT_FABLE_MODEL = global.anthropic.claude-fable-5-1
✔ Verified as arn:aws:sts::12345678012:assumed-role/AWSReservedSSO_BedrockInference_3ec244f92f7499f7/mikelim
❯ 1. Save
2. Cancel
↑/↓ to navigate · Enter to select · Esc to go back
You can start using Claude Code CLI on Amazon Bedrock
IAM Identity Center
For SSO profile, edit ~/.claude/settings.json file, and enable automatic credential refresh by using awsAuthRefresh parameter.
For example, if you are using SSO profile of name BedrockInference, add the following line
"awsAuthRefresh": "aws sso login --profile BedrockInference",
Your setttings.json file will look similar to below
{
"awsAuthRefresh": "aws sso login --profile BedrockInference",
"env": {
"CLAUDE_CODE_USE_BEDROCK": "1",
"AWS_REGION": "ap-southeast-1",
"AWS_PROFILE": "BedrockInference",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "global.anthropic.claude-sonnet-5",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "global.anthropic.claude-opus-5-5",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "global.anthropic.claude-haiku-5-5",
"ANTHROPIC_DEFAULT_FABLE_MODEL": "global.anthropic.claude-fable-5-1"
},
The above configuration will configure Claude to activate IdC browser login process whenever credentials have expired
▐▛███▛█ Claude Code v2.1.283
▝▜██████▀ Opus 5.5 · Amazon Bedrock
▝▝ ▝▝ C:\
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Authentication │
│ │
│ Attempting to open your default browser. If the browser does not open, open the following URL. If you are unable to open the URL
on this device, run this command again with the '--use-device-code' option. https://oidc.ap-southeast-1.amazonaws.com/authorize?
response_type=code&client_id=LkpDleFxsFhjEahEK2o7hWFwLXNvdXRoZWFzdC0x&redirect_uri=http%3A%2F%2F127.0.0.1%3A55
481%2Foauth%2Fcallback&state=ee9a310c-744e-4387-b016-355cc0a312c8&code_challenge_method=S256&scopes=sso%3Aaccount
%3Aaccess&code_challenge=NTa12DbtL-udKC7ikn0KuFJtACz7V9a5TVP2tLujjeE │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Optional: Visual Studio Code
To use Claude Code in VS Code, refer to Claude Code Docs Visual Studio Code section
More information
Refer to Claude Code on Amazon Bedrock for details, other configuration methods, and up-to-date guidance
Feature availability
Refer to Claude Code Docs for details
Agent Toolkit for AWS
To give Claude Code the tools, knowledge, and guardrails to build production-ready infrastructure on AWS, you can install Agent Toolkit for AWS. Refer to this article for installation guidance
- Language
- English
Relevant content
asked 5 months ago
AWS OFFICIALUpdated 23 days ago