> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mutagent.io/llms.txt
> Use this file to discover all available pages before exploring further.

# AWS Bedrock AgentCore in your own account

> Run your workspace's sandboxes on AWS Bedrock AgentCore in your own AWS account: what to set up, what Mutagent can do there, how to connect and how to revoke.

Connect your own AWS account, and AWS Bedrock AgentCore in that account becomes a sandbox provider of
your workspace, in the region you pick. Make it the workspace default, or name it for a run, and
cloud sandboxes, cloud sessions and Factory runs start there. The account stays yours: Mutagent
holds no AWS keys and can do only what the setup stack allows. At any time, you can remove the
connection in Mutagent, or cut off Mutagent's access yourself in IAM.

You give three things: a name, a region and, at most, one role ARN. Your coding agent does the rest:
it creates the setup stack and verifies the connection. You don't write IAM policies, and you don't
pick storage.

## Before you start

* **A region with AgentCore Runtime.** The Connect dialog lists the regions you can pick, whichever
  platform you choose. AgentCore Runtime is not offered on platform V2 for arm64 in US West
  (N. California), Asia Pacific (Hyderabad), the China regions or AWS GovCloud, so those regions can't
  host a connection.
* **Permission to create IAM roles and an ECR repository** in that account, for whoever runs the
  setup stack: you, or the AWS CLI profile your coding agent uses.
* **AgentCore quotas.** A new account's default Bedrock AgentCore quotas are enough for one
  workspace. If the account already runs AgentCore agents, check **Service Quotas → Amazon Bedrock
  AgentCore** for concurrent sessions and runtimes.
* **A Mutagent workspace** in which you can change the configuration.

## Two IDs

Each connection has two IDs. Keep them apart:

| ID | Looks like | Where you use it |
| - | - | - |
| `<connection-id>` | The connection's full ID in Mutagent | Mutagent commands and the API (`verify`, `set-default`, `remove`), and the provider name `aws-agentcore:<connection-id>`. `connect --json` returns it as `id`, and `mutagent sandbox providers` lists every connection of the workspace, pending ones included, with its `id` and status (`mutagent sandbox providers --json` also gives it in the provider name). |
| `<short-id>` | 12 lowercase letters and digits | AWS only: it ends the name of every resource the setup creates and starts every runtime name (`mtgc_<short-id>_…`). The connection card shows it as **Short id**, `connect --json` returns it as `shortId`, and the setup prompt and link carry it. |

## What gets created

One CloudFormation stack, `mutagent-sandbox-<short-id>`, in the region you pick. It creates three
resources, each named with the connection's short ID:

| Resource | Name | What it is for |
| - | - | - |
| Controller role | `MutagentSandboxController-<short-id>` | The only way into your account for Mutagent. Only Mutagent can use it, and only for this connection. |
| Execution role | `MutagentSandboxExecution-<short-id>` | The role AgentCore runs your sandboxes with. Mutagent never assumes it. |
| ECR repository | `mutagent-sandbox-<short-id>` | Holds the sandbox image. Mutagent fills it; you never push to it. |

Runtimes are not part of the stack: Mutagent creates them later, one connection's runtimes all named
`mtgc_<short-id>_…`.

The downloaded template is the exact definition of these resources, with every setting and
permission: review it, or reproduce it with your own tooling. You get it through a private link
that works for one hour (see [Connect with your coding agent](#connect-with-your-coding-agent)).

Each connection also has an **ExternalId**, a value Mutagent generates for it. Mutagent presents it
whenever it uses the controller role, which ties the role to your connection.

## Connect with your coding agent

This is the quickest way. Your coding agent needs the AWS CLI, signed in to the account you are
connecting.

**1. Start the connection**

In the web app, open **Configuration → Sandbox Providers** and press **Connect AWS account** on the
**AWS Bedrock AgentCore** card. Enter a name and pick a region. Leave the platform on **V2**
unless you have a reason to pick V1 (see [Platform V2 or V1](#platform-v2-or-v1)).

**2. Copy the setup prompt**

Press **Copy setup prompt** and paste it into your coding agent (Claude Code, or any agent that
can run the AWS CLI). The prompt names the connection and the region and fills in every value the
stack needs. The template itself is private: the prompt carries a presigned link to it that works
for one hour. If it has expired, press **Continue setup** on the connection's card, or run
`mutagent sandbox providers setup '<connection-id>'`, for a fresh one. Don't connect again for a fresh
link: that creates a second connection. The agent reads the downloaded template, shows you a
short summary of what it creates and asks you before it creates anything.

**3. Let the agent run it**

The agent checks which AWS account it is signed in to, deploys the setup stack with
`aws cloudformation deploy`, waits for it, reads `ControllerRoleArn` and verifies the connection
with `mutagent sandbox providers verify`. If it can't run the Mutagent CLI, it gives you the ARN:
press **I have the role ARN** in the dialog, paste it into the **Controller role ARN** field and
press **Verify**.

**4. Wait for ready**

While it is open, the dialog follows the connection. Once it is verified, Mutagent copies the sandbox image into
your repository, and the dialog shows **Verified. Copying the sandbox image to your account…**,
then **Verified. Ready to run sandboxes.** If the copy fails, it shows **Verified. Image copy
failed: retry it on the card.** The connection's card is on the same page, under **Connections**,
in the **AWS Bedrock AgentCore** group. It shows **Copying image** (`syncing`), then **Ready**
(`ready`), and sandboxes can start there. Until it is **Ready**, a launch on it is refused with
`SANDBOX_CONNECTION_NOT_READY`. See [Use the connection](#use-the-connection) to make it the default.

From the CLI, the same flow starts with `connect`. Its JSON output carries the connection's ID
(`id`), the ExternalId, the setup prompt (`setup.agentPrompt`), the quick-create link
(`setup.quickCreateUrl`) and the template link (`setup.templateUrl`). Both links are valid for one
hour. `mutagent sandbox providers setup '<connection-id>'` prints the setup again with fresh links
while the connection is `pending`, `error` or `revoked`:

```bash theme={null}
mutagent sandbox providers connect aws-agentcore --region eu-central-1 --name prod-eu --json
mutagent sandbox providers verify '<connection-id>' --role-arn '<ControllerRoleArn>' --wait --json
```

## Connect in the AWS console

If you'd rather click through it yourself:

**1. Start the connection**

Press **Connect AWS account** on the **AWS Bedrock AgentCore** card, as above.

**2. Create the stack**

Press **Open AWS setup**. The AWS console opens CloudFormation's quick-create page with the
template and all its parameters filled in by the link. Review it, acknowledge that it creates IAM
roles with custom names, and press **Create stack**. **Download template** gives you the same file to review, or to apply your own way (see [Connect with your own tooling](#connect-with-your-own-tooling)).

**3. Verify**

When the stack is complete, copy its `ControllerRoleArn` output, press **I have the role ARN**,
paste it into the **Controller role ARN** field and press **Verify**.

## Connect with your own tooling

The setup prompt and the **Open AWS setup** link create the resources with CloudFormation. If you
manage your infrastructure elsewhere (Terraform, your own pipeline), create them there instead:

1. Press **Connect AWS account** and continue to the setup step, as above. Press **Download
   template**: it is the exact definition of what to create. The setup prompt and the **Open AWS
   setup** link carry the values it needs.
2. Create the same three resources, exactly as the downloaded template defines them: the same names,
   trust policies and permissions.
3. Press **I have the role ARN**, paste the controller role's ARN into the **Controller role ARN**
   field and press **Verify** (or run `mutagent sandbox providers verify`). Verify checks the role, never a stack, so
   it works however you created the resources. It does not compare your resources with the template:
   Verify fails at once on a role or repository with another name, or a trust policy that doesn't tie
   the role to this connection. Any other difference shows up later, when Mutagent needs it.

## What Mutagent can do in your account

* Apart from listing (below), Mutagent can only create, run and clean up this connection's
  sandboxes in the region you picked: the runtimes named `mtgc_<short-id>_…`, the stack's repository
  and the execution role it hands to AgentCore. It can't change or use another connection's runtimes.
* Two listings reach beyond this connection, because AWS allows no narrower scope for listing:
  Mutagent can list the AgentCore runtimes in the region, and the sandboxes can list the log groups in
  the region. They see the names and basic details of those runtimes and log groups, but can't read
  a runtime's settings or the logs themselves.
* It uses no models in your account. Sandboxes call models with your workspace's
  [LLM providers](https://docs.mutagent.io/platform/providers/overview.md), and model use in your account is denied outright.
* It holds no AWS keys. It only gets temporary access, each time it needs it, through the
  controller role, which you control: change or delete that role and its access ends.

It can do nothing else in your account. The downloaded template lists every permission exactly.

## Image delivery

There is nothing to choose or maintain. Mutagent copies its sandbox image into the stack's repository
when the connection is verified, and again whenever Mutagent releases a new sandbox image. Images are
copied by digest, so your account runs exactly the image Mutagent tested. Layers already in your
repository are skipped.

A launch can't start on an image that isn't in your repository yet:

* During the first copy, before the connection is **Ready**, a launch is refused with
  `SANDBOX_CONNECTION_NOT_READY`.
* When the connection is **Ready** but the image a launch asks for isn't in your repository yet (for
  example right after a new Mutagent release), the launch is refused with `SANDBOX_IMAGE_NOT_SYNCED`.

Neither refusal queues the launch, and no sandbox starts: launch again once the copy is done.

A copy that fails is retried; if it still fails, the connection card shows **Image copy failed**, the
error and **Retry image copy**. When the first copy fails, the connection stays `syncing`, and
`mutagent sandbox providers` lists its status as `syncing (image copy failed)`, with the verify command
that retries the copy.

## Platform V2 or V1

New connections run on AgentCore platform **V2**, and that is the right choice for most accounts. On
V2, each session starts from a snapshot of a runtime that has already started, so sessions start
faster. The first start of a runtime takes a few minutes while AgentCore builds the snapshot.

Pick **V1** only if your organization has not approved V2. It does not widen the regions you can
connect: the region list is the same for both. The platform applies to runtimes created after you set
it: sessions already running keep theirs. To switch an existing connection:

```bash theme={null}
CONNECTION_ID='<connection-id>' # replace with the connection's full ID
curl -X PATCH "https://api.mutagent.io/api/sandbox/connections/$CONNECTION_ID" \
  -H "x-api-key: $MUTAGENT_API_KEY" -H "Content-Type: application/json" \
  -d '{"platformVersion": "V1"}'
```

## Use the connection

Each connection is a sandbox provider named `aws-agentcore:<connection-id>`. A new connection is not
the default: runs keep starting where they did until you choose it.

* **Make it the workspace default.** When it is `ready`, press the star in the top corner of its
  card: the filled star marks the workspace default. Press the star on **Mutagent Cloud** to move
  back. From the CLI:

  ```bash theme={null}
  mutagent sandbox providers set-default '<connection-id>'
  mutagent sandbox providers --json
  ```

  Factory runs and gateway runs of the workspace follow the workspace default too.

* **Name it for one run** with `--sandbox-provider aws-agentcore:<connection-id>`. A run's
  `--sandbox-provider` always wins over the default, in both directions. See
  [Sandbox providers](https://docs.mutagent.io/platform/sandbox/providers.md).

A launch on your connection never moves to Mutagent Cloud or anywhere else. If the connection can't
start a sandbox, the launch is refused with an error that names the connection and the fix.

## Revoke access

Two ways, and you can use both: remove the connection in Mutagent, which ends its use and cleans up
its runtimes, or cut off Mutagent's access yourself in IAM.

**Remove the connection in Mutagent.** Press **Remove** on its card and confirm (or run
`mutagent sandbox providers remove <connection-id> --yes`). Launches on it stop at once and its
running sandboxes are stopped. Mutagent deletes the runtimes it created there; the connection stays
**Removing** until Mutagent has confirmed that cleanup, then it disappears. If AWS already refuses
Mutagent's sign-in, for example after you cut access in IAM, there is nothing Mutagent can clean up:
the connection disappears without that confirmation, so check for runtimes yourself (step 2 below).
Removing changes nothing in IAM: your stack, and the controller role in it, stay until you delete
them.

**To leave nothing behind**, in this order:

1. Remove the connection in Mutagent, while it still has access: that lets it stop sandboxes and
   delete its runtimes.
2. Check that no runtime named `mtgc_<short-id>_…` is left: in the AgentCore console, or with
   `aws bedrock-agentcore-control list-agent-runtimes`. Delete any that is. Once the stack is gone,
   Mutagent can no longer clean them up.
3. After removing the runtimes, delete any remaining `/aws/bedrock-agentcore/runtimes/mtgc_<short-id>_*`
   log groups in CloudWatch Logs if you don't need to retain their logs.
4. Delete the stack `mutagent-sandbox-<short-id>` in CloudFormation. Deleting the stack also empties
   and deletes the repository. If the stack delete fails on the repository, delete the images in the ECR
   console and retry. If you created the resources with your own tooling, delete them there instead,
   emptying the repository first.

### Cut access from your AWS console

The controller role is yours, so you can also close it yourself in IAM, without going through
Mutagent. Stop new sign-ins first, then end the access Mutagent already has:

1. **Stop new sign-ins.** In the IAM console, open `MutagentSandboxController-<short-id>`, and under
   **Trust relationships** replace the trust policy with one that allows no one (or delete the role,
   or the whole stack, to cut access for good).

   IAM changes take effect after a short delay. Then check the cutoff with Verify, which signs in
   afresh: run
   `mutagent sandbox providers verify '<connection-id>' --role-arn '<ControllerRoleArn>'`, or call
   `POST /api/sandbox/connections/<connection-id>/verify` with the `controllerRoleArn`. The cutoff
   holds when Verify fails because AWS refuses Mutagent's sign-in to the role; the card then shows
   **Check failed** with AWS's refusal. If Verify still passes, or fails for another reason, wait a
   little and check the trust policy again. The card's **Verify again** button appears only once the
   connection shows **Check failed** or **Access revoked**, so a **Ready** connection is verified from
   the CLI or the API.

2. **End the access it already has.** Once Verify reports that AWS refuses the sign-in, use
   **Revoke active sessions** on the same role. AWS then denies every request made with a session
   issued before that moment.

After the cutoff the connection is no longer `ready`: your Verify leaves it in `error`, and a request
of Mutagent's own that AWS refuses marks it `revoked`. Every launch on it is refused with
`SANDBOX_CONNECTION_NOT_READY` and a fix. Nothing moves to another provider, before or after.
Runtimes still in your account stay there until you delete them. When you are ready, finish with
[To leave nothing behind](#revoke-access) above; Mutagent can't help with it any more, so check each
step yourself.

## Troubleshooting

When Verify fails, the connection shows **Check failed**, and the card shows what failed and how to fix
it. The usual causes:

| What you see | What to do |
| - | - |
| Mutagent can't sign in to the controller role | Create the stack from this connection's setup prompt or **Open AWS setup** link, so it belongs to this connection. Check that the ARN is from the account you meant to connect, and that its trust policy was not changed. |
| Mutagent refuses the role because it is not tied to this connection | Use the template's trust policy unchanged, or recreate the stack. |
| The execution role or the repository is missing | Check that the stack finished (`CREATE_COMPLETE`) in the connection's region and was not edited. Recreate it if a resource is gone. |
| AgentCore does not answer in the region | Check that the region is one the Connect dialog lists (see [Before you start](#before-you-start)) and that no policy in your organization blocks AgentCore. |

Fix the cause, then press **Continue setup** on the card and **Verify** in the dialog, or run `verify`
again. **Verify again** is on the card itself once the connection has passed a verify before. For a
connection that shows **Check failed** or **Access revoked**, **Continue setup** opens the dialog at the
Verify step; **Back** shows a fresh setup prompt and link, as does
`mutagent sandbox providers setup '<connection-id>'`. Use them if the fix needs a new stack and the
setup link has expired.

Other errors you may see:

| Error | Fix |
| - | - |
| `INVALID_CONTROLLER_ROLE` | The ARN is not this connection's controller role. Paste the `ControllerRoleArn` output of the stack created for this connection: the role name ends with its short ID. |
| `REGION_NOT_SUPPORTED` | The region is not one a connection can use, on either platform. Pick one from the list. |
| `CONNECTION_NAME_TAKEN` | The workspace already has a connection with that name. Pick another. |
| `SANDBOX_CONNECTION_NOT_READY` | A launch named a connection that is not `ready`, for example while the first image copy runs (`syncing`). The error carries its status, the failing check and the fix. A `revoked` connection means its controller role can no longer be assumed: recreate the stack and verify again, or remove the connection. |
| `SANDBOX_IMAGE_NOT_SYNCED` | The connection is `ready`, but the image the launch asks for isn't in your repository yet, for example right after a new Mutagent release. Retry in a few minutes, or press **Retry image copy** on the card if the copy failed. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.