---
title: "Claude Code Bedrock Setup: Env Vars, IAM Policy, and Fixing Errors"
description: "Set up Claude Code on AWS Bedrock: required env vars, credential sources, a minimal IAM policy, and fixes for model access, region, and permission errors."
url: https://cdnping.org/en/blog/claude-code-aws-bedrock-setup
language: en
published: 2026-11-17
category: "Developer tools"
tags: ["Claude Code","AWS Bedrock","IAM","Environment variables","Troubleshooting"]
source: cdnping.org
license: Free to quote and summarize with a link to the url above.
---
# Claude Code Bedrock Setup: Env Vars, IAM Policy, and Fixing Errors

Running Claude Code on AWS Bedrock comes down to three things: set `CLAUDE_CODE_USE_BEDROCK=1`, specify an AWS region, and make sure AWS credentials can be found. After that, requests no longer go to Anthropic's API. They go through your AWS account to the Claude models on Bedrock, and billing and permissions are handled by AWS.

This guide covers the Claude Code Bedrock setup in that order. Variable names and IAM actions come from the official Anthropic and AWS documentation, but this configuration changes quickly, so treat the official docs as the final word on details.

## What do you need before you start?

1. An AWS account that can use Bedrock, with access already enabled for the Claude models you want in the target region. For the enablement steps, see [Using Claude through Amazon Bedrock: steps to enable model access](/en/blog/amazon-bedrock-claude-access-guide). For how Bedrock differs from the official API, see [Using Claude on AWS Bedrock: who it's for, how to enable it, and how it differs from the official API](/en/blog/aws-bedrock-claude-overview).
2. The AWS CLI installed locally (optional, but the easiest way to verify credentials).
3. Claude Code installed.

Note: with Bedrock, Claude Code does not need you to sign in to a Claude account. Authentication goes through AWS.

## Which environment variables are required?

The minimal configuration is these three:

```bash
export CLAUDE_CODE_USE_BEDROCK=1
export AWS_REGION=us-east-1        # example; use the region where you enabled the model
export AWS_PROFILE=my-profile      # or another credential method, see the next section
```

A few notes:

- You must set `AWS_REGION` explicitly. Claude Code does not read the default region from your AWS config file, and the official docs call this out.
- The default model depends on your Claude Code version and may not match the models you have enabled. Use `ANTHROPIC_MODEL` to set the main model, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` (called `ANTHROPIC_SMALL_FAST_MODEL` in older docs) to set the lightweight model for background tasks. Write the value as a Bedrock model ID, inference profile ID, or ARN. Copy the exact value from the Bedrock console or from the output of `aws bedrock list-inference-profiles` rather than typing it from memory.
- If the lightweight model lives in a different region from your main one, the official docs provide a separate region variable. Check the official docs for its name.

You can also put these in the `env` field of `settings.json`. For precedence and scope, see [Claude Code settings.json: hierarchy, precedence, and env configuration](/en/blog/claude-code-settings-json-guide).

## Where do credentials come from?

Claude Code uses the AWS SDK default credential chain, so any of the following works:

| Method | When to use it |
| --- | --- |
| `AWS_PROFILE` pointing to a local profile | Local development; the most common |
| `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` (plus `AWS_SESSION_TOKEN` for temporary credentials) | CI or temporary sessions |
| An SSO profile after `aws sso login` | Company-wide single sign-on |
| Instance role or container role | Running inside AWS, such as EC2 or ECS |
| `AWS_BEARER_TOKEN_BEDROCK` (Bedrock API key) | When you don't want to set up full IAM credentials |

SSO and temporary credentials expire. The official docs provide settings such as `awsAuthRefresh` and `awsCredentialExport` that run a refresh command automatically when credentials expire. Follow the official docs for the exact field syntax rather than guessing.

## How do you write a minimal IAM policy?

Claude Code needs at least two invoke actions, and usually a third to list inference profiles:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "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/*"
      ]
    }
  ]
}
```

This is an example following the approach in the official docs, not the only correct answer. Key points:

- When you call through a cross-region inference profile, the request may be routed to other regions, so the `foundation-model` resource scope cannot list just one region. Otherwise you can easily hit permission-denied errors.
- To tighten permissions, replace the wildcards with specific account IDs, regions, and models, but confirm everything works first and tighten afterward.
- Handle the resource scope for `ListInferenceProfiles` as described in the AWS docs; it is usually not restricted to specific resources.

## How do you verify the setup works?

First, outside Claude Code, use the AWS CLI to confirm that credentials and region are fine:

```bash
aws sts get-caller-identity
aws bedrock list-inference-profiles --region "$AWS_REGION"
```

The first command shows whether the current identity is the account and role you expect. If the second returns a list, both the region and the `ListInferenceProfiles` permission are working. Then start `claude`, run `/status` in the session to see the current authentication and model information (exact output depends on your version), and send any message. A normal reply means it works.

## How do you troubleshoot common errors?

| Symptom | What to check first |
| --- | --- |
| The model is unavailable or you lack access, or an `AccessDeniedException` mentions the model | Whether access to this model is enabled in that region. For some models, AWS may ask you to submit use-case details on first use; follow what the Bedrock console says |
| `ValidationException` saying on-demand throughput isn't supported or the model ID is invalid | Newer models often require an inference profile ID (with a region prefix) or an ARN rather than a bare model ID |
| Region-related errors, or cannot connect | Whether `AWS_REGION` is set and matches the region where you enabled the model, and whether the variable actually reached the terminal that launched `claude` |
| `AccessDeniedException` with `not authorized to perform bedrock:InvokeModel...` | Compare the action and resource ARN in the error against your IAM policy, permissions boundary, and SCPs; a cross-region profile must allow the regions involved |
| `ExpiredToken` or signature errors | SSO or temporary credentials have expired; sign in again, and check the system clock |

Two more things are easy to overlook. First, if your environment also has an Anthropic login or `ANTHROPIC_API_KEY`, behavior may differ from what you expect; for authentication conflicts, see [Claude Code auth conflict warning and 401 errors: how to fix them](/en/blog/claude-code-auth-conflict-warning). Second, a corporate proxy or gateway can affect access to AWS endpoints. In that case, set the proxy variables as described in the official docs, and for layer-by-layer network checks see [Claude Code connection timeouts and errors: a four-layer network checklist](/en/blog/claude-code-connection-troubleshooting).

## Are there other options if you don't use AWS?

Bedrock suits teams that already have an AWS account and need usage folded into AWS billing and permissions. If you don't have an AWS account, or don't want to build out IAM for this, you can also change the API endpoint to use a compatible gateway. See [Claude Code custom API endpoint, plus Codex and OpenCode base URL configuration](/en/blog/configure-custom-api-endpoint-claude-code-codex) and [Can you use Claude Code without a Claude account?](/en/blog/claude-code-without-claude-account).

Among such gateways, AGI Plan is one option. AGI Plan is a commercial partner of cdnping. It is a monthly-subscription aggregation gateway for multiple LLM providers: one subscription includes several capability groups, you pay in RMB, and no overseas credit card is needed. You keep using Claude Code and Codex and only change one endpoint address. The service states that it is not an officially authorized channel, and some models are marked as available only outside mainland China; see the [AGI Plan models page](https://agiplan.dev/models) for details. For setup steps, see the [AGI Plan getting started page](https://agiplan.dev/startup). Which path to choose depends on whether you want AWS billing and permissions or an approach that doesn't depend on an AWS account.

## How do you tell whether it's a network problem?

If requests occasionally time out, first check the probe results for the official entry points on cdnping's [Anthropic status page](/en/status/anthropic), then read [Where AI API latency from China comes from](/en/learn/ai-api-latency-china) to tell link, region, and service-side problems apart. Note that Bedrock endpoints belong to AWS and are not covered by those official-entry probes. For outages of Bedrock itself, check the AWS health status page.

## Next steps

Do these in order: confirm the model is enabled in the target region; set the three environment variables; verify with `aws sts get-caller-identity` and `list-inference-profiles`; apply the minimal IAM policy; start `claude` and send a message. If a step fails, go back to the matching row in the error table above.
