Using Claude on Amazon Bedrock with Claude Code and Cowork

Claude Code and Cowork can both run Claude on Amazon Bedrock. Model calls go to Bedrock and are billed through your AWS account. For Claude Code, set CLAUDE_CODE_USE_BEDROCK=1, choose a region, sign in with AWS credentials, then pin model IDs before you roll it out. Cowork uses a Claude Desktop configuration that IT deploys.
Both guides were read on 2026-10-31: the Claude Code page on Amazon Bedrock at code.claude.com, and the Claude Desktop guide for Amazon Bedrock at claude.com. The Claude Code page names releases up to v2.1.287, and the text says which release each note applies to.
Before you start in AWS
You need four things before Claude Code can call a model. The Claude Code page lists them as prerequisites.
- An AWS account with Amazon Bedrock access turned on.
- Access to the Claude models you plan to use, such as Claude Sonnet 4.6. In the Bedrock console, open the Model catalog, select an Anthropic model and submit the use case form. The page says access is granted immediately, and you do this once per account.
- IAM permissions for inference. The policy later in this post lists them.
- The AWS CLI. This is optional, and you only need it if you have no other way to get credentials.
If you use AWS Organizations, submit the use case form once from the management account with the PutUseCaseForModelAccess API. The caller needs the bedrock:PutUseCaseForModelAccess permission, and approval extends to child accounts.
Sign in with the wizard, or set variables by hand
For one developer, the wizard is the quickest route. Run claude, choose 3rd-party platform, then Amazon Bedrock. If you are already signed in and see the chat prompt, run /setup-bedrock instead. The wizard asks how you authenticate, asks for your region, checks which Claude models your account can invoke and lets you pin them. It saves the result to the env block of ~/.claude/settings.json, or to $CLAUDE_CONFIG_DIR/settings.json when that variable is set.
Scripted rollouts and CI jobs should set the variables directly.
export CLAUDE_CODE_USE_BEDROCK=1
export AWS_REGION=us-east-1 # optional if your AWS profile already sets a region
# export ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION=us-west-2
# export ANTHROPIC_BEDROCK_BASE_URL=https://bedrock-runtime.us-east-1.amazonaws.com
The region is read in this order: AWS_REGION, then AWS_DEFAULT_REGION, then the region on your active AWS profile, then us-east-1. The page says a value that looks like a path or contains a space is treated as unset. Run /status to see which region Claude Code resolved and where it came from.
On Bedrock, ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION has no effect unless you also set ANTHROPIC_DEFAULT_HAIKU_MODEL, or the deprecated ANTHROPIC_SMALL_FAST_MODEL. Use ANTHROPIC_BEDROCK_BASE_URL only for a custom endpoint or gateway.
Choose a credential method
Claude Code uses the AWS default credential chain, and the page lists five ways to fill it. Pick one per machine and write it down for your team.
| Method | Where the credentials come from | What the page says |
|---|---|---|
aws configure |
An IAM user’s access key, saved to the default profile in ~/.aws/credentials |
AWS advises against IAM user keys for purpose-built software and real data |
| Environment variables | AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, plus AWS_SESSION_TOKEN for temporary credentials |
Set in the current shell only |
| SSO profile | aws sso login --profile, then AWS_PROFILE |
Role credentials come from the Identity Center region in sso_region, which need not match the Bedrock region |
aws login |
Browser sign-in with AWS Management Console credentials | Needs AWS CLI 2.32.0 or later. The session lasts up to 12 hours |
| Amazon Bedrock API key | AWS_BEARER_TOKEN_BEDROCK |
Short-term keys last up to 12 hours. When this variable is set, Claude Code skips the credential chain |
Claude Code keeps resolved credentials in memory until five minutes before they expire, or for one hour if they carry no expiry. A credential error from the API clears the cache. To resolve the chain on every request, set CLAUDE_CODE_SKIP_AWS_CRED_CACHE=1. The page gives the SSO flow as two commands:
aws sso login --profile=your-profile-name
export AWS_PROFILE=your-profile-name
Refresh expired credentials automatically
Two settings in your Claude Code settings file refresh AWS credentials, and they fire in different cases. awsAuthRefresh runs only when Claude Code sees that credentials have expired, either from their timestamp or after an API credential error. awsCredentialExport runs at session start and on each reload, even when the default chain still works.
{
"awsAuthRefresh": "aws sso login --profile myprofile",
"env": {
"AWS_PROFILE": "myprofile"
}
}
Before it runs awsAuthRefresh, Claude Code makes an STS GetCallerIdentity call and skips the command if the credentials still work. Use awsCredentialExport only when you cannot change the .aws directory. It must print JSON with a Credentials object, and the page says the flat output of aws configure export-credentials --format process is accepted too. If browser sign-in tabs keep opening, remove awsAuthRefresh and run aws sso login by hand before you start Claude Code.
Pin model versions before rollout
Pin specific model IDs when you deploy to more than one person. The page says unpinned aliases such as sonnet and opus resolve to Claude Code’s built-in Bedrock default. That default can lag the newest release, and it may not be enabled in your account.
export ANTHROPIC_DEFAULT_OPUS_MODEL='us.anthropic.claude-opus-4-8'
export ANTHROPIC_DEFAULT_SONNET_MODEL='us.anthropic.claude-sonnet-4-6'
export ANTHROPIC_DEFAULT_HAIKU_MODEL='us.anthropic.claude-haiku-4-5-20251001-v1:0'
The IDs use the us. cross-region prefix. Use eu., apac. or an application inference profile ARN if your account needs them, and us-gov. in GovCloud. Opus models cost more per token than Sonnet models, so the page’s warning applies: an unpinned primary model bills at the Opus rate. Background tasks such as session titles use the small, fast model, which on Bedrock defaults to Sonnet. Set ANTHROPIC_DEFAULT_HAIKU_MODEL to an ID your account has if you want Haiku there instead.
If you only want to keep the built-in models and change their region prefix, set ANTHROPIC_BEDROCK_REGION_PREFIX instead of pinning. The page shows the difference:
| You set | The opus alias resolves to |
|---|---|
ANTHROPIC_DEFAULT_OPUS_MODEL='us.anthropic.claude-opus-4-8' |
us.anthropic.claude-opus-4-8, the ID you pinned |
ANTHROPIC_BEDROCK_REGION_PREFIX=eu |
eu.anthropic.claude-opus-5-5, the built-in default with your prefix |
Lock the model list in managed settings
Pins set a default. An allowlist limits which models the startup checks use. The page documents enforceAvailableModels for that, and it needs Claude Code v2.1.287 or later. Deploy the file with your other managed settings. The managed settings guide covers the file locations and MDM.
{
"availableModels": [
"us.anthropic.claude-opus-4-8",
"us.anthropic.claude-sonnet-4-6",
"us.anthropic.claude-haiku-4-5-20251001-v1:0"
],
"enforceAvailableModels": true
}
The checks compare each entry with the inference profile ID they would send, region prefix included, so write the list in those IDs. This list matches the three pins in the previous section: Opus 4.8, Sonnet 4.6 and Haiku 4.5, all as us. profiles. Keep the two in step: a pinned ID that isn’t in the list is excluded from the startup checks. If you leave out enforceAvailableModels, the list does not restrict the startup checks.
The IAM policy Claude Code needs
Create a dedicated AWS account for Claude Code if you can. The page says that makes cost tracking and access control simpler. Then attach a policy like this one, which the page gives in full.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowModelAndInferenceProfileAccess",
"Effect": "Allow",
"Action": [
"bedrock:InvokeModel",
"bedrock:InvokeModelWithResponseStream",
"bedrock:ListInferenceProfiles",
"bedrock:GetInferenceProfile"
],
"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"
}
}
}
]
}
bedrock:GetInferenceProfile lets Claude Code resolve an application inference profile ARN to its base model. Without it, Claude Code retries once with the other request shape, so requests still succeed but each new model adds a round trip. The page notes this matters most for bearer-token deployments. The Mantle endpoint uses its own bedrock-mantle: actions, so this policy does not cover it.
Limits to check before rollout
These are the limits the Claude Code page lists. Test each one with your own team’s workflow before you promise it.
- WebSearch is not available on Amazon Bedrock.
/logoutis unavailable, because authentication runs through AWS credentials.- Claude Code calls the Bedrock Invoke API. It does not support the Converse API.
- From v2.1.287, Fable models, Sonnet 5 and later, and Opus 4.7 and later run with the 1M-token context window by default on Bedrock. Set
CLAUDE_CODE_DISABLE_1M_CONTEXT=1to keep the 200K window. - If a gateway sits between Claude Code and Bedrock, it must pass the
application/vnd.amazonaws.eventstreamresponse type through unchanged. A gateway that rewrites it totext/event-streammakes Claude Code reject the response.
Claude Cowork on Bedrock
The Claude Code page does not cover Cowork. Anthropic’s Claude Desktop guide for Amazon Bedrock does, and this section draws only on that guide. Cowork is set up in the Claude Desktop configuration, and the AWS steps run once per AWS organization.
| Method | Per-user identity in CloudTrail | Notes from the guide |
|---|---|---|
Bearer token (inferenceBedrockBearerToken) |
No, shared key | A proof of concept. The guide says it is not recommended for broad rollout |
In-app AWS sign-in (inferenceBedrockSso*) |
Yes | No AWS CLI needed. Users sign in through IAM Identity Center inside the app |
Named profile (inferenceBedrockProfile) |
Yes | Needs AWS CLI v2 on each device and a pushed ~/.aws/config |
Identity provider sign-in (inferenceIdpOidc) |
At your proxy | Needs a proxy at inferenceBedrockBaseUrl, because Bedrock endpoints reject identity provider tokens |
Set up Cowork on Bedrock
The Cowork setup has five steps. The AWS steps run once per AWS organization. Set the configuration keys once on an evaluation device, export the profile, and deploy it through MDM.
- Enable the Claude models in the region you will set as
inferenceBedrockRegion. Access is granted per region. - Create an IAM Identity Center permission set with the inline policy below, and set its session duration to between 8 and 12 hours.
- Note the access portal URL, the Identity Center region, the account ID and the permission set name.
- Assign the permission set to the account that hosts Bedrock, and assign the users or groups.
- Set the configuration keys, export the profile and deploy it.
For in-app AWS sign-in, the permission set needs this inline policy:
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": [
"bedrock:InvokeModel",
"bedrock:InvokeModelWithResponseStream"
],
"Resource": "*"
}]
}
The session duration controls how long each set of AWS credentials lasts, not how often users sign in. For step 5, set the keys below in the configuration window on an evaluation device, under Developer, then Configure Third-Party Inference. Export a .mobileconfig file for macOS or a .reg file for Windows, and deploy it through MDM.
inferenceProvider bedrock
inferenceBedrockRegion us-west-2
inferenceBedrockSsoStartUrl https://d-xxxxxxxxxx.awsapps.com/start
inferenceBedrockSsoRegion us-east-1
inferenceBedrockSsoAccountId 123456789012
inferenceBedrockSsoRoleName BedrockInference
inferenceModels ["us.anthropic.claude-sonnet-5"]
The Cowork example lists us.anthropic.claude-sonnet-5, while the Claude Code page pins Sonnet 4.6. Pick model IDs your account has enabled, and keep the Claude Code pins and the Cowork model list in step.
Cowork governance points from the guide
Every user in one managed configuration signs in to the same account and role, so give different groups separate profiles with different inferenceBedrockSsoRoleName values. With in-app sign-in, the app stores the IAM Identity Center tokens in the macOS Keychain or Windows DPAPI. The access portal session defaults to 8 hours and can be set up to 90 days. Deleting a user’s session in IAM Identity Center forces a sign-in sooner.
Enforcing this with AIControls
The settings in this post decide where requests go, which models run and which AWS identity signs them. With in-app sign-in or named profiles, CloudTrail already records which user made each call. What AWS does not give you is a spending limit per developer or per session. AIControls adds that layer for Claude Code. It routes Claude Code through the gateway for CLI and VS Code use, issues per-user tokens, and sets per-user and per-session cost and budget limits. Start with the coding agents guide, then read the AIControls platform page.
The earlier posts in this series cover the parts you need next: routing Claude Code through an AI gateway, and auditing what your coding agent did.
Frequently asked questions
Do I need the AWS CLI to use Claude Code on Bedrock?
No. The AWS CLI is optional. Claude Code uses the default AWS SDK credential chain, so it works with credentials already on the machine, such as an instance profile, or with an Amazon Bedrock API key in AWS_BEARER_TOKEN_BEDROCK. Some sign-in methods do need the CLI: aws configure, the SSO profile flow and aws login. The aws login command requires AWS CLI 2.32.0 or later, according to the Claude Code Bedrock page.
Why does an unpinned Claude Code install bill at the Opus rate on Bedrock?
Without ANTHROPIC_DEFAULT_OPUS_MODEL, the opus alias resolves to Claude Code's built-in Bedrock default, which the page lists as Opus 5.5 for the primary model. Opus models have a higher per-token price than Sonnet models, so an unpinned primary model is billed at the Opus rate. To run Sonnet as the primary model, set ANTHROPIC_MODEL to its full model ID. Pin the model variables before you roll out to more than one person.
Does Claude Cowork on Bedrock show which developer made each request?
It depends on the sign-in method. The Cowork guide says in-app AWS sign-in and the named profile give per-user CloudTrail identity. The bearer token is a shared key, so CloudTrail cannot tell users apart. With identity provider sign-in, identity is recorded at your proxy. Choose the method before rollout, because every user in one managed configuration signs in to the same AWS account and permission set.
Which Claude Code version do I need for enforceAvailableModels on Bedrock?
Claude Code v2.1.287 or later. The Bedrock page says that when you set enforceAvailableModels in managed settings, the startup model checks use only the models in availableModels, and that this applies on the Invoke API. A list without enforceAvailableModels does not restrict those checks. Write each entry as the inference profile ID Claude Code would send, including its region prefix such as us.