

# Set up permissions and prerequisites for Claude Managed Agents

Claude Managed Agents runs the agent loop and calls the model in the service. The tools a session uses, such as `bash` and the file tools, run in a tool runner in your own account. This topic shows how to create the resources your account needs.


| What | Name | What it is for | 
| --- | --- | --- | 
| Session role | `ClaudeManagedAgentsSessionRole` | The service assumes it to call the model and to start and stop your tool runner. Give it to your agents as their `execution_identity` role; their sessions run as it. | 
| Tool runner role | `CmaToolRunnerRuntimeRole` | The role the tool runner's container runs as in AgentCore. | 
| ECR repository | `cma-tool-runner` | Holds the tool runner image. | 
| AgentCore Runtime | `cma_tool_runner` | Runs one tool runner container per session. | 
| Caller policy | `ClaudeManagedAgentsCaller` | Lets your applications call the API and pass the session role. | 

You can create these [in the console](#claude-managed-agents-bedrock-account-setup-set-it-up-in-the-console) or [with AWS CloudFormation](#claude-managed-agents-bedrock-account-setup-set-it-up-with-cloudformation). The CloudFormation template creates the same resources. If you only want to run tools on your own machines, you need the session role, the caller policy, and a tool runner role that may only connect, `CmaSelfHostedToolRunnerRole` (the template's `CreateSelfHostedRole` parameter creates it). The caller policy denies `bedrock:CreateAnthropicSessionConnection`, so a caller role can't connect a tool runner. You can skip the repository and the runtime. See [Run the tool runner in a self-hosted environment](claude-managed-agents-bedrock-self-hosted.md).

## Prerequisites
<a name="claude-managed-agents-bedrock-account-setup-prerequisites"></a>
+ The values in the following table. The examples in this guide use US West (Oregon). In another Region, put that Region's code in the API base URL and in every ARN, and set your agent's model to a model ID that Amazon Bedrock offers there, such as `eu.anthropic.claude-sonnet-5-5` in the EU Regions or `global.anthropic.claude-sonnet-5-5` in any supported Region. Which cross-Region inference profiles a model has depends on the model and the Region. See [Supported Regions and models for inference profiles](inference-profiles-support.md). See [Supported Regions and endpoints](claude-managed-agents-bedrock.md#claude-managed-agents-bedrock-endpoints).
+ The tool runner bundle, [`claude-managed-agents-tool-runner.zip`](https://docs.aws.amazon.com/bedrock/latest/userguide/samples/claude-managed-agents-tool-runner.zip). It contains `bin/`, with a tool runner build for each platform, `image/`, with the `Dockerfile` for the AgentCore image, and `cma-account.yaml`, the CloudFormation template. Run the build commands below from the bundle's folder.
+ AWS CLI version 2, including `aws configure export-credentials`; `curl` with `--aws-sigv4` support; and `jq`.
+ Docker with `buildx`, to build the tool runner image. Python 3.10 or later with boto3, to run the [examples](claude-managed-agents-bedrock-examples.md).
+ Access to the Claude models you plan to use in Amazon Bedrock, in your Region.


| Value | US West (Oregon) | 
| --- | --- | 
| Service principal | `bedrock.amazonaws.com` | 
| API base URL | `https://bedrock.us-west-2.amazonaws.com/anthropic/v1` | 

Work in one Region. The runtime, the repository, and your API calls must all be in it.

## Configure AWS credentials and Region
<a name="claude-managed-agents-bedrock-account-setup-configure-aws-credentials-and-region"></a>

Configure an AWS profile using your organization's authentication method. For IAM Identity Center, see [Configure the AWS CLI with IAM Identity Center](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html). Select the profile that you use to create resources:

```bash
export AWS_PROFILE=my-deployment-profile
export AWS_REGION=us-west-2
aws sts get-caller-identity
```

Check that the returned account is the account where you intend to create resources. An existing `AWS_REGION` or `AWS_DEFAULT_REGION` environment variable can override a profile's default Region.

## Understand the IAM roles
<a name="claude-managed-agents-bedrock-account-setup-understand-the-iam-roles"></a>


| Identity or role | Purpose | 
| --- | --- | 
| Deployment identity | Creates the roles, repository, runtime, and policy in this topic. It can be a different identity from the caller. | 
| Caller | Signs your application's API requests. It needs the `ClaudeManagedAgentsCaller` policy, and must be an IAM role session. | 
| Session role | The service assumes it to call the model, to call AgentCore Gateways, and to start and stop the session's container on your AgentCore Runtime. | 
| Tool runner role | On AgentCore, the role the tool runner's container runs as. Self-hosted, a role that may only connect, which the tool runner signs its connection with. | 

## Set it up in the console
<a name="claude-managed-agents-bedrock-account-setup-set-it-up-in-the-console"></a>

### Step 1: Create the session role
<a name="claude-managed-agents-bedrock-account-setup-step-1-create-the-session-role"></a>

1. Open the IAM console, choose **Roles**, then **Create role**.

1. Choose **Custom trust policy** and paste the following policy, with your account ID in place of `111122223333`.

   ```json
   {
     "Version": "2012-10-17",
     "Statement": [
       {
         "Sid": "CmaForThisAccountsSessions",
         "Effect": "Allow",
         "Principal": { "Service": "bedrock.amazonaws.com" },
         "Action": "sts:AssumeRole",
         "Condition": {
           "StringEquals": { "aws:SourceAccount": "111122223333" },
           "ArnLike": { "aws:SourceArn": "arn:aws:bedrock:us-west-2:111122223333:project/*/anthropic-session/*" }
         }
       }
     ]
   }
   ```

   The service uses the role to start tool runners, call the model, and call your gateways. When a session with S3 folders or files is created, it also uses the role to read the runtime's platform version. The conditions let it assume the role only for a session in your own account.

1. Skip **Add permissions**. Name the role `ClaudeManagedAgentsSessionRole`. Under **Add tags**, add the key `ManagedAgentsExecutionRole` with the value `enabled`, then create the role.

   Every session role must carry this tag. The service assumes only roles that have it, so it cannot use any of your other roles that trust `bedrock.amazonaws.com`.

1. Open the role, choose **Add permissions**, then **Create inline policy**, and paste the following in the JSON editor. Name it `cma-session`.

   ```json
   {
     "Version": "2012-10-17",
     "Statement": [
       {
         "Sid": "CallTheModel",
         "Effect": "Allow",
         "Action": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"],
         "Resource": [
           "arn:aws:bedrock:us-west-2:111122223333:inference-profile/*.anthropic.*",
           "arn:aws:bedrock:*::foundation-model/anthropic.*",
           "arn:aws:bedrock:us-west-2:111122223333:project/*"
         ]
       },
       {
         "Sid": "RunTheToolRunner",
         "Effect": "Allow",
         "Action": ["bedrock-agentcore:InvokeAgentRuntime", "bedrock-agentcore:StopRuntimeSession"],
         "Resource": [
           "arn:aws:bedrock-agentcore:us-west-2:111122223333:runtime/cma_tool_runner-*",
           "arn:aws:bedrock-agentcore:us-west-2:111122223333:runtime/cma_tool_runner-*/runtime-endpoint/*"
         ]
       }
     ]
   }
   ```

The service calls the model through the cross-Region inference profile that the agent's model ID names, so a call can be served in any Region that profile covers. For example, a `us.` model ID stays in US Regions, an `eu.` model ID stays in EU Regions, and a `global.` model ID can be served in any commercial Region. Other geographic prefixes, such as `jp.`, `au.`, and `in.`, work the same way. That is why the foundation model statement names every Region. If your agents call an AgentCore Gateway, add a statement allowing `bedrock-agentcore:InvokeGateway` on that gateway's ARN.

Amazon Bedrock also checks each model call against the session's Amazon Bedrock project, so the role must allow the model actions on that project's ARN. `project/*` allows sessions in every project of the account and Region. To allow only some projects, list each project's ARN, such as `arn:aws:bedrock:us-west-2:111122223333:project/proj_01AbC...`, and keep `project/default` in the list. Every turn of a session whose role doesn't allow its project fails. See [Projects](claude-managed-agents-bedrock-security.md#claude-managed-agents-bedrock-security-projects).

If your sessions mount S3 folders or copy S3 files, add a statement allowing `bedrock-agentcore:GetAgentRuntime` on `arn:aws:bedrock-agentcore:us-west-2:111122223333:runtime/cma_tool_runner-*`. When such a session is created, the service reads the runtime's platform version and refuses the session if the runtime is on V1, because V1 containers cannot mount them. Without this statement, a session on a V1 runtime is created, but every start of its container fails. The service's read also appears in your CloudTrail as an `AccessDenied` `GetAgentRuntime` call by the session role. It appears at most about once per runtime and role every five minutes while such sessions are created.

### Step 2: Create the tool runner role
<a name="claude-managed-agents-bedrock-account-setup-step-2-create-the-tool-runner-role"></a>

1. In **Roles**, choose **Create role**, then **Custom trust policy**, and paste the following.

   ```json
   {
     "Version": "2012-10-17",
     "Statement": [
       {
         "Effect": "Allow",
         "Principal": { "Service": "bedrock-agentcore.amazonaws.com" },
         "Action": "sts:AssumeRole",
         "Condition": {
           "StringEquals": { "aws:SourceAccount": "111122223333" },
           "ArnLike": { "aws:SourceArn": "arn:aws:bedrock-agentcore:us-west-2:111122223333:*" }
         }
       }
     ]
   }
   ```

1. Skip **Add permissions**, name the role `CmaToolRunnerRuntimeRole`, and create it.

1. Add an inline policy named `runtime`:

   ```json
   {
     "Version": "2012-10-17",
     "Statement": [
       {
         "Effect": "Allow",
         "Action": ["ecr:BatchGetImage", "ecr:GetDownloadUrlForLayer"],
         "Resource": "arn:aws:ecr:us-west-2:111122223333:repository/cma-tool-runner"
       },
       { "Effect": "Allow", "Action": "ecr:GetAuthorizationToken", "Resource": "*" },
       {
         "Effect": "Allow",
         "Action": [
           "logs:CreateLogGroup", "logs:CreateLogStream",
           "logs:PutLogEvents", "logs:DescribeLogStreams"
         ],
         "Resource": "arn:aws:logs:us-west-2:111122223333:log-group:/aws/bedrock-agentcore/runtimes/*"
       },
       { "Effect": "Allow", "Action": "logs:DescribeLogGroups", "Resource": "*" },
       {
         "Effect": "Allow",
         "Action": [
           "bedrock-agentcore:GetWorkloadAccessToken",
           "bedrock-agentcore:GetWorkloadAccessTokenForJWT"
         ],
         "Resource": "arn:aws:bedrock-agentcore:us-west-2:111122223333:workload-identity-directory/default*"
       },
       {
         "Effect": "Allow",
         "Action": "bedrock:CreateAnthropicSessionConnection",
         "Resource": "arn:aws:bedrock:us-west-2:111122223333:project/*/anthropic-session/*"
       }
     ]
   }
   ```

The last statement lets the tool runner connect to the service to run a session's tools. For sessions that mount S3 folders or copy S3 files, also add the S3 policy in [Use S3 folders and files](claude-managed-agents-bedrock-s3-folders-and-files.md).

**Important**  
Any command the model runs in the container can use this role's permissions. Give the role only what your agents' commands need.

### Step 3: Create the repository and push the image
<a name="claude-managed-agents-bedrock-account-setup-step-3-create-the-repository-and-push-the-image"></a>

1. Open the Amazon ECR console, choose **Create repository**, keep it private, and name it `cma-tool-runner`.

1. Build the image from the bundle. AgentCore runs Linux ARM64 containers only, and the `Dockerfile` only copies files, so this works on an x86 machine without emulation.

   ```bash
   mkdir build && cd build
   cp ../image/Dockerfile ../LICENSE ../NOTICE ../THIRD-PARTY-NOTICES .
   cp ../bin/cma-tool-runner-linux-arm64 cma-tool-runner
   chmod 755 cma-tool-runner
   mkdir workspace
   docker buildx build --pull --platform linux/arm64 --load -t cma-tool-runner .
   ```

   The image's CA bundle comes from the latest Amazon Linux 2023 image. `--pull` makes Docker fetch that image instead of using an older copy that it cached. Rebuild and push a new tag from time to time to pick up Amazon Linux's CA updates.

1. Push it. The repository's **View push commands** shows the same login command.

   ```bash
   REPO=111122223333.dkr.ecr.us-west-2.amazonaws.com/cma-tool-runner
   aws ecr get-login-password --region us-west-2 \
     | docker login --username AWS --password-stdin "${REPO%%/*}"
   docker tag cma-tool-runner "$REPO:v1"
   docker push "$REPO:v1"
   ```

Use a new tag for each new bundle, so the runtime update in Step 4 picks up the new image.

**Important**  
Any command that the model runs in this runtime can get `CmaToolRunnerRuntimeRole`'s credentials, and in public network mode it can connect to any host. Before your agents read content you don't control, read [Protect the tool runner](claude-managed-agents-bedrock-security.md#claude-managed-agents-bedrock-security-protect-the-tool-runner).

If you build your own image instead, its entrypoint must start the tool runner as `cma-tool-runner agentcore`. A tool runner started with no mode prints its usage and exits, and the session never gets its tools.

For sessions that mount S3 folders or copy S3 files, build the image from `image/Dockerfile.s3-mounts` instead. See [Use S3 folders and files](claude-managed-agents-bedrock-s3-folders-and-files.md).

**Note**  
For faster `grep` on large directories, add ripgrep (`rg`) to your image. The tool runner uses it when it is on `PATH`. Set `CMA_TOOL_RUNNER_RIPGREP` to a path to use another binary, or to `none` to keep the built-in search.

### Step 4: Create the AgentCore Runtime
<a name="claude-managed-agents-bedrock-account-setup-step-4-create-the-agentcore-runtime"></a>

1. Open the Amazon Bedrock AgentCore console, choose **Runtime**, and create an agent runtime.

1. Use the following settings.


<table>
<thead>
  <tr><th>Setting</th><th>Value</th></tr>
</thead>
<tbody>
  <tr><td>Name</td><td><code>cma_tool_runner</code></td></tr>
  <tr><td>Image</td><td>The URI you pushed in Step 3, such as <code>111122223333.dkr.ecr.us-west-2.amazonaws.com/cma-tool-runner:v1</code></td></tr>
  <tr><td>Execution role</td><td><code>CmaToolRunnerRuntimeRole</code></td></tr>
  <tr><td>Network mode</td><td>Public. The tool runner connects out to the service's public endpoint.</td></tr>
  <tr><td>Protocol</td><td>HTTP</td></tr>
  <tr><td>Idle session timeout</td><td>900 seconds</td></tr>
</tbody>
</table>


1. Wait for the runtime to be **Ready**, and copy its ARN. A session names this ARN as its `environment_id`.

For sessions that mount S3 folders or copy S3 files, create the runtime on platform version V2. V1 is AgentCore's default, and its containers cannot mount them.

The session role's permissions in Step 1 name the runtime `cma_tool_runner` (its ID is `cma_tool_runner-` followed by a suffix). If you pick another name, change that policy to match.

The first AgentCore Runtime in an account creates the service-linked role `AWSServiceRoleForBedrockAgentCoreRuntimeIdentity`. If the identity you create runtimes with has narrow permissions, it needs `iam:CreateServiceLinkedRole` for `runtime-identity.bedrock-agentcore.amazonaws.com`. You can also create the role once yourself:

```bash
aws iam create-service-linked-role --aws-service-name runtime-identity.bedrock-agentcore.amazonaws.com
```

The same applies when you deploy the CloudFormation template.

### Step 5: Give your applications permission to call the API
<a name="claude-managed-agents-bedrock-account-setup-step-5-give-your-applications-permission-to-call-the-api"></a>

Create a customer managed policy named `ClaudeManagedAgentsCaller`, and attach it to the IAM roles your applications run as:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ClaudeManagedAgents",
      "Effect": "Allow",
      "Action": "bedrock:*Anthropic*",
      "Resource": "arn:aws:bedrock:us-west-2:111122223333:project/*"
    },
    {
      "Sid": "NotAToolRunner",
      "Effect": "Deny",
      "Action": "bedrock:CreateAnthropicSessionConnection",
      "Resource": "*"
    },
    {
      "Sid": "GiveAgentsModelsAndGateways",
      "Effect": "Allow",
      "Action": ["bedrock:CreateAnthropicAgent", "bedrock:UpdateAnthropicAgent"],
      "Resource": [
        "arn:aws:bedrock:us-west-2:111122223333:inference-profile/*.anthropic.*",
        "arn:aws:bedrock-agentcore:us-west-2:111122223333:gateway/*",
        "arn:aws:s3:::*"
      ]
    },
    {
      "Sid": "OverrideTheSessionServersAndSkills",
      "Effect": "Allow",
      "Action": "bedrock:CreateAnthropicSession",
      "Resource": [
        "arn:aws:bedrock-agentcore:us-west-2:111122223333:gateway/*",
        "arn:aws:s3:::*"
      ]
    },
    {
      "Sid": "PatchTheSessionServers",
      "Effect": "Allow",
      "Action": "bedrock:UpdateAnthropicSession",
      "Resource": "arn:aws:bedrock-agentcore:us-west-2:111122223333:gateway/*"
    },
    {
      "Sid": "StartSessionsOnYourRuntimes",
      "Effect": "Allow",
      "Action": "bedrock:CreateAnthropicSession",
      "Resource": "arn:aws:bedrock-agentcore:us-west-2:111122223333:runtime/*"
    },
    {
      "Sid": "OverrideTheSessionModel",
      "Effect": "Allow",
      "Action": "bedrock:CreateAnthropicSession",
      "Resource": "arn:aws:bedrock:us-west-2:111122223333:inference-profile/*"
    },
    {
      "Sid": "PassTheSessionRole",
      "Effect": "Allow",
      "Action": "iam:PassRole",
      "Resource": "arn:aws:iam::111122223333:role/ClaudeManagedAgentsSessionRole",
      "Condition": {
        "StringEquals": { "iam:PassedToService": "bedrock.amazonaws.com" },
        "ArnLike": {
          "iam:AssociatedResourceArn": [
            "arn:aws:bedrock:us-west-2:111122223333:project/*/anthropic-agent/*",
            "arn:aws:bedrock:us-west-2:111122223333:project/*/anthropic-session/*"
          ]
        }
      }
    }
  ]
}
```

The second statement keeps these roles from connecting a tool runner to a session, which only the tool runner's role needs. A role that could connect would receive a session's tool calls in place of its tool runner.

The third statement lets these roles give agents a model, AgentCore Gateways, and S3 skill folders. Creating an agent checks `bedrock:CreateAnthropicAgent` on the agent, on the model's inference profile ARN, on each gateway its `mcp_servers` name, and on each S3 folder of its `s3_mount` skills (`arn:aws:s3:::<bucket>/<folder>/`). An update checks the ones it sets. To narrow the statement, name the inference profiles, gateways, and folders instead of the wildcards. An agent can use a gateway in another Region if you add that gateway's ARN to this statement. Because this statement scopes the gateway resource to this account, a gateway ARN in another account is denied by this policy. The service doesn't block a cross-account gateway on its own: a gateway in another account can be reached only if you broaden this resource and that gateway's own resource policy grants your session role.

The fourth and fifth statements do the same for a session that overrides its agent's `mcp_servers` or `s3_mount` skills, and for an update that sets `mcp_servers`. Creating a session checks `bedrock:CreateAnthropicSession`, and updating one checks `bedrock:UpdateAnthropicSession`, on each gateway and folder the request names. It also checks each S3 folder or object in the session's own `s3_mount` and `s3_object` `resources` entries. See [Use S3 folders and files](claude-managed-agents-bedrock-s3-folders-and-files.md). A session that keeps its agent's servers and skills, and names no S3 resource, needs neither statement.

The sixth statement lets these roles start sessions on your AgentCore Runtimes. Creating a session checks `bedrock:CreateAnthropicSession` on the runtime's ARN as well as on the project's resources. To narrow it, name your runtimes instead of `runtime/*`. A runtime belongs to the account, not to a project, so naming one project in this policy does not limit which runtimes its sessions use. To keep projects' runtimes apart, see Projects.

The seventh statement lets these roles start a session that overrides its agent's model. That checks `bedrock:CreateAnthropicSession` on the model's inference profile, `arn:aws:bedrock:us-west-2:111122223333:inference-profile/<model id>`, and the check also sees the agent's tags. A session that keeps its agent's model needs no such permission. To limit which models can be chosen, name profiles instead of `inference-profile/*`.

Creating an agent, or changing its role, checks `iam:PassRole`, associated with the agent ARN. A session create that names a role in `execution_identity` or the `x-amz-role-arn` header checks it too, associated with the new session's ARN. Applications that only create and update sessions, and name no role, don't need the last statement, because their sessions inherit the chosen agent's role. To narrow the policy, name one project instead of `project/*`. Name both `arn:aws:bedrock:us-west-2:111122223333:project/<project id>`, for listing, and `arn:aws:bedrock:us-west-2:111122223333:project/<project id>/*`, for everything in it, including creating agents, sessions, and memory stores. Creating a session also needs the grants on its environment and the other resources described above. To give a principal read-only access to sessions, use the matching `Get` and `List` actions, including `GetAnthropicSessionEventsWithResponseStream` for streaming.

**Create a role to call as**

The API accepts only IAM role credentials, and neither the console steps nor the template create a role for the caller policy. If your application does not already run as a role, create one, attach the policy, and add a profile that assumes it:

```bash
ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
CALLER=arn:aws:iam::${ACCOUNT}:policy/ClaudeManagedAgentsCaller

cat > cma-caller-trust.json <<EOF
{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Principal": { "AWS": "arn:aws:iam::${ACCOUNT}:root" },
    "Action": "sts:AssumeRole"
  }]
}
EOF
aws iam create-role --role-name CmaCaller \
  --assume-role-policy-document file://cma-caller-trust.json
aws iam attach-role-policy --role-name CmaCaller --policy-arn "$CALLER"

aws configure set profile.cma-caller.role_arn arn:aws:iam::${ACCOUNT}:role/CmaCaller
aws configure set profile.cma-caller.source_profile my-deployment-profile
aws configure set profile.cma-caller.region us-west-2
aws sts get-caller-identity --profile cma-caller --query Arn --output text
```

The last command should print an `assumed-role/CmaCaller/...` ARN. A trust policy that names the account root delegates to the account, so the identity you assume the role from also needs `sts:AssumeRole` on `CmaCaller` in its own policy. Without it, assuming the role fails with `AccessDenied`. Use `cma-caller` as `AWS_PROFILE` for the API calls in this guide.

**Important**  
This role only calls the API. It needs no permission to create IAM roles, repositories, runtimes, or stacks. Keep those permissions on the deployment identity that runs CloudFormation, and do not attach them to the caller role.

### Step 6: Allow AWS review if your agents use Claude Fable
<a name="claude-managed-agents-bedrock-account-setup-step-6-allow-aws-review-if-your-agents-use-claude-fable"></a>

Skip this step unless an agent names a Claude Fable model, such as `us.anthropic.claude-fable-5-1`. Amazon Bedrock runs Fable only when your account's data retention mode is `aws_review`. In any other mode, every turn on a Fable agent ends in `model_request_failed_error`, and the session's role is not the cause. Set the mode in the Region you use:

```bash
aws bedrock get-account-data-retention --region us-west-2
aws bedrock put-account-data-retention --region us-west-2 --mode aws_review
```

**Important**  
The mode applies to every Amazon Bedrock call in the account, not only to Claude Managed Agents. In `aws_review` mode, AWS keeps prompts and outputs for up to 30 days, inside AWS, so that Amazon staff can review them for safety. Decide whether that is acceptable for your account before you set it. See [Amazon Bedrock data retention](data-retention.md).

## Set it up with CloudFormation
<a name="claude-managed-agents-bedrock-account-setup-set-it-up-with-cloudformation"></a>

The template `cma-account.yaml`, in the tool runner bundle's folder, creates everything in the console steps except the data retention mode, which you set yourself if your agents use Fable. It cannot build the image, so you deploy it twice: once to create the repository, and again after you push the image.

1. Create the stack without an image. This makes the roles, the repository, and the caller policy.

   ```bash
   aws cloudformation deploy --region us-west-2 \
     --stack-name claude-managed-agents \
     --template-file cma-account.yaml \
     --capabilities CAPABILITY_NAMED_IAM
   ```

   In the console, choose **Create stack**, upload the template, and leave **ImageUri** empty. The defaults are the values from the prerequisites.

1. Build and push the image as in [Step 3](#claude-managed-agents-bedrock-account-setup-step-3-create-the-repository-and-push-the-image). The repository's URI is the stack's `RepositoryUri` output.

1. Deploy again with the image:

   ```bash
   aws cloudformation deploy --region us-west-2 \
     --stack-name claude-managed-agents \
     --template-file cma-account.yaml \
     --capabilities CAPABILITY_NAMED_IAM \
     --parameter-overrides ImageUri=111122223333.dkr.ecr.us-west-2.amazonaws.com/cma-tool-runner:v1
   ```

The `RuntimeArn` output is the `environment_id` for your sessions. The template creates the runtime on platform version V2, which takes a few minutes to become ready. To use a new bundle, push it under a new tag and deploy again with the new `ImageUri`.

**Optional parameters**


| Parameter | What it does | 
| --- | --- | 
| `GatewayArn` | Lets sessions call this AgentCore Gateway's tools. | 
| `CreateSelfHostedRole` | Creates `CmaSelfHostedToolRunnerRole`, a role that may only connect a tool runner on your own machine. See [Run the tool runner in a self-hosted environment](claude-managed-agents-bedrock-self-hosted.md). | 
| `SessionRoleName` | The session role's name. The default is `ClaudeManagedAgentsSessionRole`. | 
| `RuntimeName`, `RepositoryName` | Other names, if the defaults are taken. | 
| `PlatformVersion` | `V2` (default) restores each session's container from a snapshot, so a session's first tool call starts sooner. S3 folders and files need `V2`. | 
| `S3Bucket` | Gives the tool runner role the session-scoped S3 policy on this bucket (see [Use S3 folders and files](claude-managed-agents-bedrock-s3-folders-and-files.md)). Each session can list, read, and write only its own folder, and list and read the `skills` folder. It also lets the session role read the runtime (`bedrock-agentcore:GetAgentRuntime`), so a session with S3 folders or files on a `V1` runtime is refused when it is created, unless its `environment_id` names a runtime endpoint. Empty, the default, gives the tool runner role no S3 access and the session role no read of the runtime. | 
| `S3SessionsFolder`, `S3SkillsFolder` | The folders of `S3Bucket` that hold each session's own folders and the skills. The defaults are `outputs` and `skills`. | 

Apart from the session role, the template fixes its IAM role and policy names, so it fails if they already exist anywhere in the account. If you use the AWS CDK, you can add the template to an app with `cloudformation_include.CfnInclude`.

## Select a model
<a name="claude-managed-agents-bedrock-account-setup-select-a-model"></a>

Set an agent's model to an Amazon Bedrock model ID, such as `us.anthropic.claude-sonnet-5-5` in the US Regions or `eu.anthropic.claude-sonnet-5-5` in the EU Regions, or `global.anthropic.claude-sonnet-5-5`. A model ID is called as written, so its prefix decides where the model runs. A Claude model name, such as `claude-sonnet-5-5`, and a model ID with no geography, such as `anthropic.claude-sonnet-5-5`, are refused. Use a Claude model that Amazon Bedrock offers in the endpoint's Region, and make sure the session role is allowed to invoke it. Inference profile ARNs and `inference_geo` are refused, so use the model ID's prefix to choose the geography.

## Check your setup
<a name="claude-managed-agents-bedrock-account-setup-check-your-setup"></a>

Set up a shell as in [Run your first agent, Step 1](claude-managed-agents-bedrock-first-agent.md#claude-managed-agents-bedrock-first-agent-step-1-set-up-a-shell), with a profile for a role that has the caller policy. That step exports the role's credentials, which curl needs because it does not read AWS profiles. Then create an agent and a session that runs on the runtime:

```bash
AGENT_ID=$(cma POST agents -d '{
  "name": "setup-check",
  "execution_identity": {"type": "aws_role", "role_arn": "arn:aws:iam::111122223333:role/ClaudeManagedAgentsSessionRole"},
  "model": "us.anthropic.claude-sonnet-5-5",
  "tools": [{"type": "agent_toolset_20260401", "default_config": {"permission_policy": {"type": "always_allow"}}}]
}' | jq -r .id)
cma POST sessions -d '{"agent": "'"${AGENT_ID}"'", "environment_id": "'"${RUNTIME_ARN}"'"}'
```

Once the session is created, send it a `user.message` asking it to run a command with `bash`. If a tool call fails, the tool runner's log is in CloudWatch Logs under `/aws/bedrock-agentcore/runtimes/`, in the log group named for your runtime.


| Response to session create | Cause | 
| --- | --- | 
| 403 `permission_error` | The caller's role lacks the caller policy. | 
| 404 `no such route` | The base URL is wrong, or the Region is not one in [Supported Regions and endpoints](claude-managed-agents-bedrock.md#claude-managed-agents-bedrock-endpoints). | 
| 404 `no such agent` | The agent ID is wrong, or the agent is in another project. | 
| 400 invalid\_request\_error naming the role | The session role does not exist, its trust policy does not match the one in Step 1, or it lacks the ManagedAgentsExecutionRole tag. | 