

# Protecting your data using VPC and AWS PrivateLink
<a name="vpc"></a>

You can use Amazon Virtual Private Cloud (Amazon VPC) and AWS PrivateLink to create private connections between your VPC and Amazon Bedrock AgentCore.

**Topics**
+ [Use interface VPC endpoints (AWS PrivateLink) to create a private connection between your VPC and your Amazon Bedrock AgentCore resources](vpc-interface-endpoints.md)
+ [Configure Amazon Bedrock AgentCore Gateway VPC Egress for Gateway Targets](gateway-vpc-egress.md)
+ [Connect to private resources in your VPC using VPC Lattice](vpc-egress-private-endpoints.md)
+ [Configure Amazon Bedrock AgentCore Runtime and tools for VPC](agentcore-vpc.md)
+ [Use IAM condition keys with AgentCore Runtime and built-in tools VPC settings](security-vpc-condition.md)

# Use interface VPC endpoints (AWS PrivateLink) to create a private connection between your VPC and your Amazon Bedrock AgentCore resources
<a name="vpc-interface-endpoints"></a>

You can use AWS PrivateLink to create a private connection between your VPC and Amazon Bedrock AgentCore. You can access AgentCore as if it were in your VPC, without the use of an internet gateway, NAT device, VPN connection, or Direct Connect connection. Instances in your VPC don’t need public IP addresses to access AgentCore.

You establish this private connection by creating an *interface endpoint* , powered by AWS PrivateLink. We create an endpoint network interface in each subnet that you enable for the interface endpoint. These are requester-managed network interfaces that serve as the entry point for traffic destined for AgentCore.

For more information, see [Access AWS services through AWS PrivateLink](https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-access-aws-services.html) in the * AWS PrivateLink Guide*.

## Considerations for AgentCore
<a name="vpc-endpoint-considerations"></a>

Before you set up an interface endpoint for AgentCore, review [Considerations](https://docs.aws.amazon.com/vpc/latest/privatelink/create-interface-endpoint.html#considerations-interface-endpoints) in the * AWS PrivateLink Guide*.

AgentCore provides three AWS PrivateLink endpoints:
+  **Data plane endpoint** - `com.amazonaws.region.bedrock-agentcore` 
+  **Control plane endpoint** - `com.amazonaws.region.bedrock-agentcore-control` 
+  **Gateway endpoint** - `com.amazonaws.region.bedrock-agentcore.gateway` 

The following table shows AWS PrivateLink support status for each AgentCore primitive:


| Primitive | Data plane | Control plane | 
| --- | --- | --- | 
|  Runtime  |  Supported  |  Supported  | 
|  Memory  |  Supported  |  Supported  | 
|  Built-in Tools (Code Interpreter, Browser Tool)  |  Supported  |  Supported  | 
|  Identity  |  Supported  |  Supported  | 
|  Gateway  |  Supported  |  Supported  | 
|  Evaluations  |  Not yet supported  |  Supported  | 
|  Policy  |  Supported  |  Supported  | 

For a list of AWS Regions in which AgentCore interface endpoints are available, see [Supported AWS Regions](agentcore-regions.md).

**Important**  
The data plane APIs support both AWS Signature Version 4 (SigV4) headers for authentication and Bearer Token (OAuth) authentication. VPC endpoint policies can only restrict callers based on IAM principals and not OAuth users. For OAuth-based requests to succeed through the VPC endpoint, the principal must be set to \$1 in the endpoint policy. Otherwise, only SigV4 allowlisted callers can make successful calls over the VPC endpoint.

 AWS IAM global condition context keys are supported. By default, full access to AgentCore is allowed through the interface endpoint. You can control access by attaching an endpoint policy to the interface endpoint or by associating a security group with the endpoint network interfaces.

## Create an interface endpoint for AgentCore
<a name="vpc-endpoint-create"></a>

You can create an interface endpoint for AgentCore using either the Amazon VPC console or the AWS Command Line Interface (AWS CLI). For more information, see [Create an interface endpoint](https://docs.aws.amazon.com/vpc/latest/privatelink/create-interface-endpoint.html#create-interface-endpoint-aws) in the * AWS PrivateLink Guide*.

Create an interface endpoint for AgentCore using the following service name format:
+ All data plane primitives (Runtime, Built-in Tools, Memory, Identity): `com.amazonaws.region.bedrock-agentcore` 
+ For AgentCore Gateway: `com.amazonaws.region.bedrock-agentcore.gateway` 
+ For control plane operations (Runtime and Memory management): `com.amazonaws.region.bedrock-agentcore-control` 

If you enable private DNS for the interface endpoint, you can make API requests to AgentCore using its default Regional DNS name. For example, `bedrock-agentcore.us-east-1.amazonaws.com`.

## Create an endpoint policy for your interface endpoint
<a name="vpc-endpoint-policy"></a>

An endpoint policy is an IAM resource that you can attach to an interface endpoint. The default endpoint policy allows full access to AgentCore through the interface endpoint. To control the access allowed to AgentCore from your VPC, attach a custom endpoint policy to the interface endpoint.

An endpoint policy specifies the following information:
+ The principals that can perform actions (AWS accounts, IAM users, and IAM roles).
  + For AgentCore Gateway, if your gateway ingress isn’t [AWS Signature Version 4 (SigV4)](https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html) -based (for example, if you use OAuth instead), you must specify the `Principal` field as the wildcard \$1 . SigV4 -based authentication allows you to define the `Principal` as a specific AWS identity. This also applies to AgentCore Runtime.
+ The actions that can be performed.
+ The resources on which the actions can be performed.

For more information, see [Control access to services using endpoint policies](https://docs.aws.amazon.com/vpc/latest/privatelink/vpc-endpoints-access.html) in the * AWS PrivateLink Guide*.

 **Endpoint policies for various primitives** 

The following examples show endpoint policies for different AgentCore components:

**Example**  

1. The following endpoint policy allows specific IAM principals to invoke agent runtime resources.

   ```
   {
      "Statement": [
         {
            "Effect": "Allow",
            "Principal": {
               "AWS": "arn:aws::iam::ACCOUNT_ID:user/USERNAME"
            },
            "Action": [
               "bedrock-agentcore:InvokeAgentRuntime"
            ],
            "Resource": "arn:aws::bedrock-agentcore:us-east-1:ACCOUNT_ID:runtime/RUNTIME_ID"
         }
      ]
   }
   ```

    **Mixed IAM and OAuth authentication** 

   The `InvokeAgentRuntime` API supports two modes of VPC endpoint authorization. The following example policy allows both IAM principals and OAuth callers to access different agent runtime resources.

   ```
   {
      "Statement": [
         {
            "Effect": "Allow",
            "Principal": {
               "AWS": "arn:aws::iam::ACCOUNT_ID:root"
            },
            "Action": [
               "bedrock-agentcore:InvokeAgentRuntime"
            ],
            "Resource": "arn:aws::bedrock-agentcore:us-east-1:ACCOUNT_ID:runtime/customAgent1"
         },
         {
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
               "bedrock-agentcore:InvokeAgentRuntime"
            ],
            "Resource": "arn:aws::bedrock-agentcore:us-east-1:ACCOUNT_ID:runtime/customAgent2"
         }
      ]
   }
   ```

   The above policy allows only the IAM principal to make `InvokeAgentRuntime` calls to `customAgent1` . It also allows both IAM principals and OAuth callers to make `InvokeAgentRuntime` calls to `customAgent2`.

1. The following endpoint policy allows specific IAM principals to invoke Code Interpreter resources.

   ```
   {
      "Statement": [
         {
            "Effect": "Allow",
            "Principal": {
               "AWS": "arn:aws::iam::ACCOUNT_ID:root"
            },
            "Action": [
               "bedrock-agentcore:InvokeCodeInterpreter"
            ],
            "Resource": "arn:aws::bedrock-agentcore:us-east-1:ACCOUNT_ID:code-interpreter/CODE_INTERPRETER_ID"
         }
      ]
   }
   ```

1. ====== All data plane operations

   The following endpoint policy allows specific IAM principals to access us-east-1 data plane operations for a specific AgentCore Memory.

   ```
   {
      "Statement": [
         {
            "Effect": "Allow",
            "Principal": {
               "AWS": "arn:aws::iam::ACCOUNT_ID:root"
            },
            "Action": [
               "bedrock-agentcore:CreateEvent",
               "bedrock-agentcore:DeleteEvent",
               "bedrock-agentcore:GetEvent",
               "bedrock-agentcore:ListEvents",
               "bedrock-agentcore:DeleteMemoryRecord",
               "bedrock-agentcore:GetMemoryRecord",
               "bedrock-agentcore:ListMemoryRecords",
               "bedrock-agentcore:RetrieveMemoryRecords",
               "bedrock-agentcore:ListActors",
               "bedrock-agentcore:ListSessions",
               "bedrock-agentcore:BatchCreateMemoryRecords",
               "bedrock-agentcore:BatchDeleteMemoryRecords",
               "bedrock-agentcore:BatchUpdateMemoryRecords"
            ],
            "Resource": "arn:aws::bedrock-agentcore:us-east-1:ACCOUNT_ID:memory/MEMORY_ID"
         }
      ]
   }
   ```

    **Access to all memories** 

   The following endpoint policy allows specific IAM principals access to all memories.

   ```
   {
      "Statement": [
         {
            "Effect": "Allow",
            "Principal": {
               "AWS": "arn:aws::iam::ACCOUNT_ID:root"
            },
            "Action": [
               "bedrock-agentcore:CreateEvent",
               "bedrock-agentcore:DeleteEvent",
               "bedrock-agentcore:GetEvent",
               "bedrock-agentcore:ListEvents",
               "bedrock-agentcore:DeleteMemoryRecord",
               "bedrock-agentcore:GetMemoryRecord",
               "bedrock-agentcore:ListMemoryRecords",
               "bedrock-agentcore:RetrieveMemoryRecords",
               "bedrock-agentcore:ListActors",
               "bedrock-agentcore:ListSessions",
               "bedrock-agentcore:BatchCreateMemoryRecords",
               "bedrock-agentcore:BatchDeleteMemoryRecords",
               "bedrock-agentcore:BatchUpdateMemoryRecords"
            ],
            "Resource": "arn:aws::bedrock-agentcore:us-east-1:ACCOUNT_ID:memory/*"
         }
      ]
   }
   ```

    **Access restriction by APIs** 

   The following endpoint policy grants permission for a specific IAM principal to create events in a specific AgentCore Memory resource.

   ```
   {
      "Statement": [
         {
            "Effect": "Allow",
            "Principal": {
               "AWS": "arn:aws::iam::ACCOUNT_ID:root"
            },
            "Action": [
               "bedrock-agentcore:CreateEvent"
            ],
            "Resource": "arn:aws::bedrock-agentcore:us-east-1:ACCOUNT_ID:memory/MEMORY_ID"
         }
      ]
   }
   ```

1. The following endpoint policy allows specific IAM principals to connect to Browser Tool resources.

   ```
   {
      "Statement": [
         {
            "Effect": "Allow",
            "Principal": {
               "AWS": "arn:aws::iam::ACCOUNT_ID:root"
            },
            "Action": [
               "bedrock-agentcore:ConnectBrowserAutomationStream"
            ],
            "Resource": "arn:aws::bedrock-agentcore:us-east-1:ACCOUNT_ID:browser/BROWSER_ID"
         }
      ]
   }
   ```

1. The following is an example of a custom endpoint policy. When you attach this policy to your interface endpoint, it allows all principals to invoke the gateway specified in the `Resource` field.

   ```
   {
      "Statement": [
         {
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
               "bedrock:InvokeGateway"
            ],
            "Resource": "arn:aws::bedrock-agentcore:us-east-1::gateway/my-gateway"
         }
      ]
   }
   ```

1. The following endpoint policy allows access to Identity resources.

   ```
   {
      "Statement": [
         {
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
               "*"
            ],
            "Resource": "arn:aws:bedrock-agentcore:us-east-1:ACCOUNT_ID:workload-identity-directory/default/workload-identity/WORKLOAD_IDENTITY_ID"
         }
      ]
   }
   ```

# Configure Amazon Bedrock AgentCore Gateway VPC Egress for Gateway Targets
<a name="gateway-vpc-egress"></a>

The AgentCore Gateway service provides secure and controlled egress traffic management for your applications, enabling seamless communication with resources within your Virtual Private Cloud (VPC). This document outlines how egress traffic flows through the AgentCore Gateway to reach VPC resources. You’ll learn about the supported gateway target types (Lambda, API Gateway, and MCP servers via AgentCore Runtime), their configuration requirements, and the authentication methods supported for each target type. This guide covers the security considerations, routing mechanisms, and best practices needed to enable proper egress traffic flow while maintaining network isolation and following the principle of least privilege throughout your architecture.

## MCP
<a name="mcp-target"></a>

AgentCore Gateway supports Model Context Protocol (MCP) servers as target endpoints, providing flexible deployment options to meet various customer requirements. MCP servers can be configured in multiple ways depending on your infrastructure needs and security requirements.

Your MCP targets could be of two types, not hosted on AgentCore, or hosted on AgentCore Runtime or Gateway. We discuss both below.

### MCPs not hosted on AgentCore
<a name="self-hosted-mcp"></a>

AgentCore Gateway supports connecting to self-hosted MCP servers running inside your VPC using private endpoints powered by Amazon VPC Lattice. You can configure a `privateEndpoint` on your gateway target to route traffic privately to your MCP server without exposing it to the public internet.

**Important**  
VPC egress with private endpoints is made available as a "Beta Service" as defined in the AWS Service Terms.

The following example creates a private MCP server target using managed Lattice:

```
{
  "name": "my-private-mcp-target",
  "privateEndpoint": {
    "managedVpcResource": {
      "vpcIdentifier": "vpc-0abc123def456",
      "subnetIds": ["subnet-0abc123", "subnet-0def456"],
      "endpointIpAddressType": "IPV4",
      "securityGroupIds": ["sg-0abc123def"]
    }
  },
  "targetConfiguration": {
    "mcp": {
      "mcpServer": {
        "endpoint": "https://my-mcp-server.internal.example.com/mcp"
      }
    }
  }
}
```

If your MCP server uses a domain that is not publicly resolvable (for example, a private hosted zone in Route 53), you must also specify a `routingDomain` . For more information, see [Workaround for private DNS support: routing domain](vpc-egress-private-endpoints.md#lattice-vpc-egress-routing-domain).

If your MCP server uses a TLS certificate issued by a private certificate authority, you can place an internal Application Load Balancer with a public ACM certificate in front of it. For more information, see [Workaround for private certificates: ALB](vpc-egress-private-endpoints.md#lattice-vpc-egress-private-certs).

For self-managed Lattice, cross-account setups, and advanced configurations, see [Connect to private resources in your VPC using VPC Lattice](vpc-egress-private-endpoints.md).

### AgentCore Runtime or Gateway
<a name="agentcore-runtime"></a>

AgentCore Runtime provides native support for communicating with resources within your VPC through a managed infrastructure approach. All communication between AgentCore Gateway and AgentCore Runtime stays on the AWS backbone, ensuring your data never traverses the public internet (except for cross-region calls to China datacenters). For more information, see the [Connectivity](https://aws.amazon.com/vpc/faqs/#connectivity) section in the Amazon VPC FAQs. For detailed setup instructions on connecting AgentCore Runtime to your VPC, refer to the [Configure Amazon Bedrock AgentCore Runtime and tools for VPC](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/agentcore-vpc.html) 

For outbound authorization from AgentCore Gateway to AgentCore Runtime, two authentication methods are supported: no authorization (not recommended for production use) and OAuth with client credentials grant (for machine-to-machine authentication). When no authorization is configured, the request from AgentCore Gateway to AgentCore Runtime has no auth tokens. This architecture provides a seamless connection pathway while maintaining security isolation. As a security best practice, configure restrictive authentication and authorization permissions for both AgentCore Runtime and AgentCore Gateway, limiting access to only the necessary resources and operations required for your specific use case. To configure an OAuth Identity to be used by AgentCore Gateway for egress and ingress for AgentCore Runtime use the following documents:
+  [Configure an OAuth client](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/identity-oauth-client.html) 
+  [Specify the authorization type and credentials to access the gateway target](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway-building-adding-targets-authorization.html) 
+  [Authenticate and authorize with Inbound Auth and Outbound Auth](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-oauth.html) 

![\[gateway runtime vpc access\]](http://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/images/gateway-runtime-vpc-access.png)


 **Example CreateGatewayTarget with AgentCore Runtime as a the target** 

The following example shows how to create a gateway target with AgentCore Runtime:

```
POST /gateways/gatewayIdentifier/targets/ HTTP/1.1
Content-type: application/json

    {
    "clientToken": "string",
    "credentialProviderConfigurations": [
      {
         "credentialProvider": {
            "oauthCredentialProvider": {
               "providerArn": "string",
               "scopes": [ "string" ],
               ...
            }
         },
         "credentialProviderType": "OAUTH"
      }
    ],
    "description": "string",
    "metadataConfiguration": {
      "allowedQueryParameters": [ "string" ],
      "allowedRequestHeaders": [ "string" ],
      "allowedResponseHeaders": [ "string" ]
    },
    "name": "string",
    "targetConfiguration": {
      "mcp": {
         "mcpServer": {
            "endpoint": "https://bedrock-agentcore.<region>.amazonaws.com/runtimes/<runtime-id>/invocations?qualifier=DEFAULT&accountId=<account-id>"
         }
      }
    }
}
```

**Note**  
Avoid using a VPC endpoint (VPCE) URL with `privateEndpoint` to prevent an unnecessary extra network hop. Use the direct AgentCore Runtime endpoint instead, with which traffic remains on the AWS backbone.

## Open API target
<a name="openapi-target"></a>

### API Gateway endpoint via Open API Target
<a name="api-gateway-via-openapi"></a>

If your API Gateway can’t be directly added as a target, you can always export the resource as an OpenAPI spec and import the spec into AgentCore Gateway as a OpenAPI target.
+  [Export a REST API from API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-export-api.html) 
+  [OpenAPI schema targets](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway-schema-openapi.html) 

If you have Private REST APIs in API Gateway, follow the instructions here: [Private REST APIs in API Gateway](#private-api-gateway).

### Other endpoints
<a name="other-endpoints"></a>

You can configure Open API targets to reach private endpoints inside your VPC using the `privateEndpoint` configuration. AgentCore Gateway uses Amazon VPC Lattice to establish private connectivity to your endpoint without exposing it to the public internet.

**Important**  
VPC egress with private endpoints is made available as a "Beta Service" as defined in the AWS Service Terms.

The following example creates a private OpenAPI target using managed Lattice:

```
{
  "name": "my-private-openapi-target",
  "privateEndpoint": {
    "managedVpcResource": {
      "vpcIdentifier": "vpc-0abc123def456",
      "subnetIds": ["subnet-0abc123", "subnet-0def456"],
      "endpointIpAddressType": "IPV4",
      "securityGroupIds": ["sg-0abc123def"]
    }
  },
  "targetConfiguration": {
    "mcp": {
      "openApiSchema": {
        "inlinePayload": "<your OpenAPI spec JSON with server URL pointing to your private endpoint>"
      }
    }
  }
}
```

If your endpoint uses a domain that is not publicly resolvable, you must also specify a `routingDomain` . For more information, see [Workaround for private DNS support: routing domain](vpc-egress-private-endpoints.md#lattice-vpc-egress-routing-domain).

If your endpoint uses a TLS certificate issued by a private certificate authority, you can place an internal Application Load Balancer with a public ACM certificate in front of it. For more information, see [Workaround for private certificates: ALB](vpc-egress-private-endpoints.md#lattice-vpc-egress-private-certs).

For self-managed Lattice, cross-account setups, and advanced configurations, see [Connect to private resources in your VPC using VPC Lattice](vpc-egress-private-endpoints.md).

## Smithy target
<a name="smithy-target"></a>

Private endpoint ( `privateEndpoint` ) configuration is not currently supported for Smithy targets.

## API Gateway
<a name="api-gateway-target"></a>

AgentCore Gateway supports API Gateway as a target type, which can serve as an intermediary layer for accessing VPC resources. AgentCore Gateway specifically supports REST API Gateways configured with regional endpoints only. While direct VPC communication from the Gateway is not currently available (this feature is planned for future release), the gateway communicates with API Gateway over the AWS backbone, ensuring that traffic never traverses the public internet (except for cross-region calls to China datacenters). The API Gateway can then communicate with resources using VPC Link, creating a secure pathway for the AgentCore Gateway to reach internal services while maintaining network isolation.

To implement security best practices, configure your API Gateway to restrict inbound traffic exclusively to the AgentCore Gateway service principal or the configured API key, preventing unauthorized access from other sources. For outbound authorization from AgentCore Gateway to API Gateway, only two authentication methods are supported: IAM-based authentication (using the gateway service role to authenticate with AWS Signature Version 4) and API key authentication (managed by AgentCore Gateway); OAuth-based authorization and Cross Account API Gateways are not supported for API Gateway targets, please use API Gateway endpoint via Open API Target for those. Limit the AgentCore Gateway execution role permissions to invoke only the specific API Gateway endpoint required, rather than granting broad API Gateway access, ensuring that the gateway cannot interact with unintended API resources and maintaining the principle of least privilege throughout your architecture.

 [Amazon API Gateway REST API stages as targets](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway-target-api-gateway.html) 

### Permissions for API Gateway integration using IAM Auth
<a name="api-gateway-permissions"></a>

 **API Gateway Resource Policy Locked Down to AgentCore Gateway** 

The following resource policy restricts API Gateway access to AgentCore Gateway:

```
{
"Version": "2012-10-17",		 	 	 
    "Statement": [
      {
        "Effect": "Allow",
        "Principal": {
          "Service": "bedrock-agentcore.amazonaws.com"
        },
        "Action": "execute-api:Invoke",
        "Resource": [
          "arn:aws:execute-api:us-west-2:111122223333:rest-api-id/api-stage/*/*"
        ],
        "Condition": {
          "ArnEquals": {
            "aws:SourceArn": "arn:aws:bedrock-agentcore:us-west-2:111122223333:gateway/my-gateway-d4jrgkaske"
          }
        }
      }
    ]
}
```

 **AgentCore Gateway Execution Role policy** 

The following policy grants the gateway permission to invoke the API Gateway:

```
{
"Version": "2012-10-17",		 	 	 
    "Statement": [
      {
        "Effect": "Allow",
        "Action": [
          "execute-api:Invoke"
        ],
        "Resource": [
          "arn:aws:execute-api:us-west-2:111122223333:abcd123/prod/*/*"
        ]
      }
    ]
}
```

 **AgentCore Gateway Execution Role trust policy** 

The following trust policy allows AgentCore Gateway to assume the execution role:

```
{
"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:gateway/*"
          }
        }
      }
    ]
}
```

#### Private REST APIs in API Gateway
<a name="private-api-gateway"></a>

API Gateway targets with private endpoints are not natively supported. However, you can export your private API Gateway as an OpenAPI schema and use an Open API target with that schema, configured with a `privateEndpoint` . Set the `routingDomain` to your API Gateway VPC endpoint (VPCE) DNS name, and ensure the OpenAPI schema server URL uses the domain that matches your public TLS certificate.

```
{
  "name": "my-private-apigw-target",
  "privateEndpoint": {
    "managedVpcResource": {
      "vpcIdentifier": "vpc-0123456789abcdef0",
      "subnetIds": ["subnet-0123456789abcdef0", "subnet-0abcdef1234567890"],
      "endpointIpAddressType": "IPV4",
      "routingDomain": "<vpce-id>.execute-api.<region>.vpce.amazonaws.com"
    }
  },
  "targetConfiguration": {
    "mcp": {
      "openApiSchema": {
        "inlinePayload": "<OpenAPI spec JSON with server URL matching the public certificate domain for your API Gateway, for example https://<api-id>.execute-api.<region>.amazonaws.com>"
      }
    }
  }
}
```

For more details on private endpoint configuration, see [Connect to private resources in your VPC using VPC Lattice](vpc-egress-private-endpoints.md).
+  [Export a REST API from API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-export-api.html) 
+  [OpenAPI schema targets](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway-schema-openapi.html) 

## Lambda
<a name="lambda-target"></a>

AgentCore Gateway supports Lambda targets as one of it target types, allowing seamless invocation of Lambda functions that can communicate with resources within your VPC. This functionality is available out-of-the-box and requires no additional configuration from customers - the gateway can immediately invoke Lambda functions that have been configured with VPC access to reach your internal resources such as databases, APIs, or other services. To maintain security best practices, it’s strongly recommended to configure the AgentCore Gateway execution role with minimal permissions, specifically limiting it to invoke only the intended Lambda function rather than granting broad Lambda execution permissions. This principle of least privilege ensures that the gateway, or any other caller using the same role, cannot inadvertently invoke unintended Lambda functions, thereby reducing your security attack surface and maintaining strict access controls within your AWS environment.

## Workaround for private identity providers
<a name="private-idp-workaround"></a>

Configuring a private (VPC-hosted) OAuth identity provider for AgentCore Gateway inbound authorization is not yet natively supported. As a workaround, you can use an interceptor Lambda function for inbound authentication and override the Authorization header in the interceptor Lambda for use with outbound auth.
+  [Gateway interceptors](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway-interceptors.html) 
+  [Specify the authorization type and credentials to access the gateway target](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway-building-adding-targets-authorization.html) 

## Limitations and considerations
<a name="gateway-vpc-access-limitations"></a>
+  **Inbound authorization required** : Gateway targets configured with a `privateEndpoint` cannot use `NO_AUTH` as the inbound authorizer type unless an interceptor Lambda is configured on the gateway.

For additional limitations related to private DNS resolution, cross-account connectivity, and DNS TTL configuration, see [Limitations and considerations](vpc-egress-private-endpoints.md#lattice-vpc-egress-limitations) in [Connect to private resources in your VPC using VPC Lattice](vpc-egress-private-endpoints.md).

# Connect to private resources in your VPC using VPC Lattice
<a name="vpc-egress-private-endpoints"></a>

**Important**  
This feature is made available to you as a "Beta Service" as defined in the AWS Service Terms. It is subject to your Agreement with AWS and the AWS Service Terms.

Amazon Bedrock AgentCore supports private connectivity to resources hosted inside your AWS VPC or on-premises environments connected to your VPC, such as private MCP servers, internal REST APIs, or databases, without exposing those services to the public internet.

Private connectivity is established using [Amazon VPC Lattice](https://docs.aws.amazon.com/vpc-lattice/latest/ug/what-is-vpc-lattice.html) resource gateways and resource configurations. For details on the two supported modes (managed and self-managed Lattice), see [Supported VPC egress modes](#lattice-vpc-egress-compare-modes).

**Topics**
+ [Key concepts](#lattice-vpc-egress-concepts)
+ [Supported Amazon Bedrock AgentCore services](#lattice-vpc-egress-supported-services)
+ [Supported VPC egress modes](#lattice-vpc-egress-compare-modes)
+ [Option 1: Managed Lattice](#lattice-vpc-egress-managed-lattice)
+ [Option 2: Self-managed Lattice](#lattice-vpc-egress-self-managed-lattice)
+ [Workaround for private DNS support: routing domain](#lattice-vpc-egress-routing-domain)
+ [Workaround for private certificates: ALB](#lattice-vpc-egress-private-certs)
+ [Service-linked role for VPC egress](#lattice-vpc-egress-slr)
+ [Target status and troubleshooting](#lattice-vpc-egress-target-status)
+ [Limitations and considerations](#lattice-vpc-egress-limitations)

## Key concepts
<a name="lattice-vpc-egress-concepts"></a>

 **Resource Gateway**   
An Amazon VPC Lattice resource gateway is the point of ingress into your VPC. It is associated with one or more subnets and security groups in your VPC and acts as the network entry point for traffic from AgentCore. When you use managed Lattice, AgentCore creates and manages this resource on your behalf.

 **Resource Configuration**   
A resource configuration represents a specific private endpoint - an IP address or DNS name - within your VPC. It is attached to a resource gateway and defines which resource AgentCore can reach. When you use managed Lattice, AgentCore creates this resource in the AgentCore service account on your behalf.

 **Service Network Resource Association**   
A service network resource association connects a resource configuration to the AgentCore service network, enabling the AgentCore service to invoke your private endpoint. AgentCore always creates and manages this association on your behalf, regardless of whether you use managed or self-managed Lattice.

 **Routing domain**   
An optional field that specifies an intermediate publicly resolvable domain that AgentCore uses as the resource configuration domain instead of the actual target domain. This is required when your private endpoint uses a domain that is not publicly resolvable, because Amazon VPC Lattice requires publicly resolvable DNS for resource configurations. The AgentCore service continues to invoke the actual target domain using SNI override. For more information, see [Workaround for private DNS support: routing domain](#lattice-vpc-egress-routing-domain).

## Supported Amazon Bedrock AgentCore services
<a name="lattice-vpc-egress-supported-services"></a>

The following Amazon Bedrock AgentCore services support VPC egress with VPC Lattice:

 **AgentCore Gateway**   
AgentCore Gateway supports private endpoints for MCP server and OpenAPI target types. For details on configuring VPC egress for each target type, see [Configure Amazon Bedrock AgentCore Gateway VPC Egress for Gateway Targets](gateway-vpc-egress.md).

## Supported VPC egress modes
<a name="lattice-vpc-egress-compare-modes"></a>

Amazon Bedrock AgentCore supports two modes for configuring VPC Lattice connectivity:
+  **Managed Lattice** — Amazon Bedrock AgentCore creates and manages the VPC Lattice resource gateway and resource configuration on your behalf. You provide your VPC, subnets, and optional security groups. This is the simpler approach for in-account VPC connectivity that plugs into existing network architectures such as hub-and-spoke.
+  **Self-managed Lattice** — You create and manage the VPC Lattice resource gateway and resource configuration yourself. This approach provides enhanced governance and visibility: you can see exactly which services are connected to which domains, who has access, and revoke connections at a granular level. It also enables direct cross-account connectivity via AWS RAM without requiring VPC peering or Transit Gateways.

The following table summarizes the key differences:


| Dimension | Managed Lattice | Self-managed Lattice | 
| --- | --- | --- | 
|  Complexity  |  Simple — provide VPC, subnets, and security groups. Amazon Bedrock AgentCore manages the rest.  |  Advanced — you create and manage VPC Lattice resource gateways and resource configurations yourself.  | 
|  Cross-account connectivity  |  Not supported. Use with existing network architectures such as hub-and-spoke (VPC peering or AWS Transit Gateway) for cross-account or cross-VPC scenarios.  |  Supported via AWS RAM. Enables direct cross-account connectivity without requiring VPC peering or Transit Gateways.  | 
|  VPC Lattice pricing  |  Data processing charges only (per GB processed through the resource gateway).  |  Hourly charge per VPC resource added to a service network, plus data processing charges (per GB).  | 
|  Resource lifecycle  |  Amazon Bedrock AgentCore creates, reuses, and deletes resource gateways on your behalf.  |  You own the full lifecycle of resource gateways and resource configurations.  | 
|  Governance and visibility  |  Resource configurations are managed in the Amazon Bedrock AgentCore service account. You do not see them in your VPC Lattice console.  |  Full visibility into resource configurations, service network associations, and connected domains. You can audit connections and revoke access at a granular level.  | 
|  IP consumption and throughput  |  Each managed resource gateway consumes 1 IP address per subnet. This is not configurable.  |  You can configure the number of IP addresses per ENI (up to the VPC Lattice maximum) when creating the resource gateway. More IPs allow higher throughput — the combination of port range and IP addresses determines the maximum number of concurrent connections for that service network resource association. Note that there is a 350-second port cooldown period after a connection ends before that port can be reused.  | 

For VPC Lattice pricing details, see [Amazon VPC Lattice pricing](https://aws.amazon.com/vpc/lattice/pricing/).

## Option 1: Managed Lattice
<a name="lattice-vpc-egress-managed-lattice"></a>

With managed Lattice, you provide your VPC, subnet, and optional security group information. AgentCore handles the creation and lifecycle management of the VPC Lattice resource gateway and resource configuration on your behalf, and does not require you to have VPC Lattice permissions in your own IAM policies.

AgentCore uses the `AWSServiceRoleForBedrockAgentCoreGatewayNetwork` service-linked role to create and manage VPC Lattice resource gateways in your account. This role is created automatically the first time you create a gateway target with a managed private endpoint. For more information about this role, see [Gateway service-linked role](service-linked-roles.md#gateway-service-linked-role).

### Prerequisites
<a name="lattice-vpc-egress-managed-lattice-prereqs"></a>

Before creating a gateway target with a managed private endpoint, ensure the following:
+ Your private resource (MCP server or REST API) is running and accessible within your VPC.
+ You have at least one subnet in your VPC that has network access to the private resource.
+ Your security groups allow inbound traffic on the port used by your private resource (typically port 443 for HTTPS).
+ Your IAM principal has the `iam:CreateServiceLinkedRole` permission for `bedrock-agentcore.amazonaws.com` , so that AgentCore can create the service-linked role on your behalf if it does not already exist. For the required IAM policy, see [Gateway service-linked role](service-linked-roles.md#gateway-service-linked-role).
+ Your IAM principal has the following Amazon EC2 permissions, which are required for AgentCore to set up the VPC Lattice resource gateway in your VPC:
  +  `ec2:CreateNetworkInterface` 
  +  `ec2:DescribeVpcs` 
  +  `ec2:DescribeSecurityGroups` 
  +  `ec2:DescribeSubnets` 
+ If your private endpoint uses a domain that is not publicly resolvable, you must use the `routingDomain` field. For more information, see [Workaround for private DNS support: routing domain](#lattice-vpc-egress-routing-domain).
+ If your private resource uses a TLS certificate issued by a private certificate authority, you can place an internal Application Load Balancer with a public ACM certificate in front of it. For more information, see [Workaround for private certificates: ALB](#lattice-vpc-egress-private-certs).

### Create a target with a managed private endpoint
<a name="lattice-vpc-egress-managed-lattice-create"></a>

To create a resource with a managed private endpoint, include the `privateEndpoint.managedVpcResource` block in your create request.

```
{
  ...
  "privateEndpoint": {
    "managedVpcResource": {
      "vpcIdentifier": "vpc-0abc123def456",
      "subnetIds": ["subnet-0abc123", "subnet-0def456"],
      "endpointIpAddressType": "IPV4",
      "securityGroupIds": ["sg-0abc123def"]
    }
  },
  ...
}
```

The `managedVpcResource` block accepts the following fields:

 `vpcIdentifier` (required)  
The ID of the VPC that contains your private resource.

 `subnetIds` (required)  
A list of subnet IDs within the VPC where the resource gateway will be placed.

 `endpointIpAddressType` (required)  
The IP address type for the resource configuration. Valid values are `IPV4` and `IPV6`.

 `securityGroupIds` (optional)  
A list of security group IDs to associate with the resource gateway. If not provided, the default security group for the VPC is used.

 `routingDomain` (optional)  
An intermediate publicly resolvable domain to use as the resource configuration endpoint. Required when your private endpoint domain is not publicly resolvable. For more information, see [Workaround for private DNS support: routing domain](#lattice-vpc-egress-routing-domain).

 `tags` (optional)  
Tags to apply to the managed VPC Lattice resource gateway. The tag key `BedrockAgentCoreGatewayManaged` is reserved and cannot be specified.

### View managed resources
<a name="lattice-vpc-egress-managed-lattice-response"></a>

After the resource is created, call the relevant Get API (for example, `GetGatewayTarget` ) to view the managed VPC Lattice resources that AgentCore created on your behalf. These are returned in the `privateEndpointManagedResources` field of the response:

```
{
  ...
  "status": "READY",
  "privateEndpoint": {
    "managedVpcResource": {
      "vpcIdentifier": "vpc-0abc123def456",
      "subnetIds": ["subnet-0abc123", "subnet-0def456"],
      "endpointIpAddressType": "IPV4",
      "securityGroupIds": ["sg-0abc123def"]
    }
  },
  "privateEndpointManagedResources": [
    {
      "domain": "my-server.internal.example.com",
      "resourceGatewayArn": "arn:aws:vpc-lattice:us-east-1:123456789012:resourcegateway/rgw-abc123"
    }
  ]
}
```

The `resourceGatewayArn` is the ARN of the VPC Lattice resource gateway that AgentCore created in your account. AgentCore manages the full lifecycle of this resource: it reuses the same resource gateway for targets with matching VPC and subnet configurations, and deletes it when it is no longer used by any targets.

## Option 2: Self-managed Lattice
<a name="lattice-vpc-egress-self-managed-lattice"></a>

With self-managed Lattice, you create and manage the VPC Lattice resource gateway and resource configuration yourself, then provide the resource configuration identifier to AgentCore. Use this option if you already have VPC Lattice resources configured, need to share a resource configuration across multiple services, or require control over the Lattice resource lifecycle.

### Prerequisites
<a name="lattice-vpc-egress-self-managed-lattice-prereqs"></a>

Before creating a gateway target with a self-managed private endpoint, complete the following steps:
+ Your private resource (MCP server or REST API) is running and accessible within your VPC.
+ You have at least one subnet in your VPC that has network access to the private resource.
+ Your security groups allow inbound traffic on the port used by your private resource (typically port 443 for HTTPS).
+ If your private endpoint uses a domain that is not publicly resolvable, you must use the `routingDomain` field. For more information, see [Workaround for private DNS support: routing domain](#lattice-vpc-egress-routing-domain).
+ If your private resource uses a TLS certificate issued by a private certificate authority, you can place an internal Application Load Balancer with a public ACM certificate in front of it. For more information, see [Workaround for private certificates: ALB](#lattice-vpc-egress-private-certs).

 **Set up VPC Lattice resources for self-managed connectivity** 

1.  **Create a Resource Gateway** in your VPC using the VPC Lattice console or the `CreateResourceGateway` API. Associate it with the subnets and security groups that have access to your private resource.

   ```
   aws vpc-lattice create-resource-gateway \
     --name my-resource-gateway \
     --vpc-identifier vpc-0abc123def456 \
     --subnet-ids subnet-0abc123 subnet-0def456 \
     --security-group-ids sg-0abc123def \
     --ip-address-type IPV4
   ```

1.  **Create a Resource Configuration** that points to your private endpoint. Use the ARN of the resource gateway you created in the previous step.

   ```
   aws vpc-lattice create-resource-configuration \
     --name my-resource-config \
     --type SINGLE \
     --resource-gateway-identifier <resource-gateway-arn> \
     --resource-configuration-definition '{"dnsResource": {"domain": "my-service.internal.example.com", "ipAddressType": "IPV4"}}' \
     --port-ranges 443
   ```

1.  **If the resource is in a different account** than the AgentCore owner account, share the resource configuration with the AgentCore owner account using AWS RAM:

   ```
   aws ram create-resource-share \
     --name my-resource-config-share \
     --resource-arns <resource-configuration-arn> \
     --principals <gateway-owner-account-id>
   ```

   The AgentCore owner account must accept the resource share before creating the target.

1. Note the resource configuration ARN or ID. You will provide this as the `resourceConfigurationIdentifier` when creating the gateway target.

Your IAM principal also needs the following permissions to allow AgentCore to associate the resource configuration with the AgentCore service network on your behalf:

```
{
"Version": "2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "vpc-lattice:GetResourceConfiguration",
        "vpc-lattice:CreateServiceNetworkResourceAssociation",
        "vpc-lattice:GetServiceNetworkResourceAssociation",
        "vpc-lattice:ListServiceNetworkResourceAssociations",
        "vpc-lattice:AssociateViaAWSService"
      ],
      "Resource": "*"
    }
  ]
}
```

### Create a target with a self-managed private endpoint
<a name="lattice-vpc-egress-self-managed-lattice-create"></a>

To create a resource with a self-managed private endpoint, include the `privateEndpoint.selfManagedLatticeResource` block in your create request:

```
{
  ...
  "privateEndpoint": {
    "selfManagedLatticeResource": {
      "resourceConfigurationIdentifier": "arn:aws:vpc-lattice:us-east-1:123456789012:resourceconfiguration/rcfg-abc123"
    }
  },
  ...
}
```

The `resourceConfigurationIdentifier` can be either the ARN or the ID of the VPC Lattice resource configuration. AgentCore uses your credentials (via [Forward Access Sessions](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_forward_access_sessions.html) ) to associate the resource configuration with the AgentCore service network.

After the resource is created, the Get API response includes the `resourceAssociationArn` in the `privateEndpointManagedResources` field. If you create multiple resources pointing to the same resource configuration, AgentCore automatically reuses the existing service network resource association.

### Cross-account private resources
<a name="lattice-vpc-egress-cross-account"></a>

You can connect AgentCore to private resources in a different AWS account than the account that owns the gateway. This is a common pattern for platform teams that manage centralized gateways while individual service teams own the private resources.

The resource owner account must share the VPC Lattice resource configuration with the gateway owner account using AWS RAM. The gateway owner account then provides the shared resource configuration identifier when creating the gateway target.

The following steps summarize the cross-account setup:

 **Set up cross-account private connectivity** 

1.  **In the resource owner account** : Create a VPC Lattice resource gateway and resource configuration as described in [Prerequisites](#lattice-vpc-egress-self-managed-lattice-prereqs).

1.  **In the resource owner account** : Share the resource configuration with the gateway owner account using AWS RAM:

   ```
   aws ram create-resource-share \
     --name my-resource-config-share \
     --resource-arns <resource-configuration-arn> \
     --principals <gateway-owner-account-id>
   ```

1.  **In the gateway owner account** : Accept the resource share:

   ```
   aws ram accept-resource-share-invitation \
     --resource-share-invitation-arn <invitation-arn>
   ```

1.  **In the gateway owner account** : Create the gateway target using the shared resource configuration identifier, as described in [Create a target with a self-managed private endpoint](#lattice-vpc-egress-self-managed-lattice-create).

## Workaround for private DNS support: routing domain
<a name="lattice-vpc-egress-routing-domain"></a>

Amazon VPC Lattice requires that the domain used in a resource configuration be publicly resolvable. If your private endpoint uses a domain that is only resolvable within your VPC (for example, a private hosted zone in Route 53), you must use the `routingDomain` field.

When using a routing domain, the domain you specify for your target (in the MCP endpoint URL or OpenAPI server URL) should be the actual private DNS name of your resource - i.e. the name that is resolvable within your VPC. The `routingDomain` is a separate, publicly resolvable domain that AgentCore uses only to set up the VPC Lattice resource configuration. At invocation time, AgentCore routes traffic through the routing domain but sends requests with the private DNS name as the TLS SNI hostname, so your resource receives requests addressed to its actual private domain.

The routing domain can be any publicly resolvable domain that routes to your private resource within the VPC — including any existing component in your architecture that already has a publicly resolvable DNS name. Common options include:
+  **VPC endpoint (VPCE) domain for a private API Gateway** - Use the VPCE DNS name as the `routingDomain` , for example `<vpce-id>.execute-api.us-east-1.vpce.amazonaws.com` . Set the target URL in your OpenAPI spec to the private API Gateway hostname, for example `https://<api-id>.execute-api.us-east-1.amazonaws.com` . AgentCore routes traffic through the VPCE domain but sends requests with the private API hostname as the TLS SNI, ensuring correct routing within your VPC.
+  **Internal Application Load Balancer (ALB)** - Use the internal ALB DNS name as the `routingDomain` , for example `internal-<alb-name>-<id>.us-west-2.elb.amazonaws.com` . Set the target URL to the private DNS name of the resource behind the ALB.
+  **Internal Network Load Balancer (NLB)** - Use the internal NLB DNS name as the `routingDomain` , for example `internal-<nlb-name>-<id>.elb.us-west-2.amazonaws.com` . Set the target URL to the private DNS name of the resource behind the NLB.

The following steps describe the traffic flow when a routing domain is used:

1. AgentCore resolves the VPC Lattice-generated DNS name to reach the resource gateway.

1. Traffic enters your VPC through the resource gateway, addressed to the routing domain.

1. The routing domain (VPCE or ALB) forwards the request to your private resource. The TLS SNI header contains the actual target domain, so your resource receives the request with the correct hostname.

### Example: Private API Gateway with VPCE routing domain
<a name="lattice-vpc-egress-routing-domain-setup"></a>

The following example shows how to create a gateway target for a private API Gateway using its VPCE domain as the routing domain. The target URL is the private API Gateway hostname, and the `routingDomain` is the VPCE DNS name:

```
{
  "name": "my-private-apigw-target",
  "privateEndpoint": {
    "managedVpcResource": {
      "vpcIdentifier": "vpc-0123456789abcdef0",
      "subnetIds": ["subnet-0123456789abcdef0", "subnet-0abcdef1234567890"],
      "endpointIpAddressType": "IPV4",
      "routingDomain": "<vpce-id>.execute-api.us-east-1.vpce.amazonaws.com"
    }
  },
  "targetConfiguration": {
    "mcp": {
      "openApiSchema": {
        "inlinePayload": "<OpenAPI spec JSON with server URL matching the public certificate domain, for example https://<api-id>.execute-api.<region>.amazonaws.com>"
      }
    }
  }
}
```

**Note**  
The `routingDomain` field is only available for the `managedVpcResource` option. For self-managed Lattice, configure the routing domain directly in your resource configuration when you create it.

## Workaround for private certificates: ALB
<a name="lattice-vpc-egress-private-certs"></a>

VPC egress requires your target endpoint to have a publicly trusted TLS certificate. If your private resource uses a certificate issued by a private certificate authority (CA), the recommended workaround is to place an internal Application Load Balancer (ALB) in front of your resource.

The following steps describe the traffic flow:

1. Set the target URL to a domain that matches your public ACM certificate (for example, `https://my-server.my-company.com` ).

1. Set the `routingDomain` to the internal ALB DNS name (for example, `internal-my-alb-1234567890.us-west-2.elb.amazonaws.com` ).

1. VPC Lattice routes traffic to the ALB via the routing domain. The TLS SNI is set to `my-server.my-company.com` , which matches the ALB’s public ACM certificate, so the TLS handshake succeeds.

1. The ALB terminates TLS and applies a host header transform to rewrite the Host header from `my-server.my-company.com` to the private resource’s domain (for example, `my-server.my-company.internal` ).

1. The ALB forwards the request to your backend resource over HTTPS using the private certificate. All traffic stays inside your VPC.

 **Step 1: Request a public ACM certificate** 

Request a public certificate from ACM for a domain you own. This domain will be used as the target URL. For instructions, see [Request a public certificate](https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request-public.html) in the AWS Certificate Manager User Guide.

 **Step 2: Create an internal ALB** 

Create an internal Application Load Balancer in the same VPC as your private resource. For instructions, see [Create an Application Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/create-application-load-balancer.html) in the Elastic Load Balancing User Guide. Ensure you set the scheme to `internal`.

 **Step 3: Create an IP-based target group** 

Create a target group with target type `ip` that points to your private resource’s IP address on port 443 (HTTPS), and register your private resource as a target. For instructions, see [Create a target group](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/create-target-group.html) in the Elastic Load Balancing User Guide.

 **Step 4: Create an HTTPS listener with host header transform** 

Create an HTTPS listener on port 443 using the public ACM certificate. Add a listener rule that transforms the Host header from the public domain to the private resource’s domain before forwarding.

```
aws elbv2 create-listener \
  --load-balancer-arn <alb-arn> \
  --protocol HTTPS \
  --port 443 \
  --certificates CertificateArn=<acm-certificate-arn> \
  --default-actions '[{
    "Type": "forward",
    "TargetGroupArn": "<target-group-arn>",
    "ForwardConfig": {
      "TargetGroups": [{"TargetGroupArn": "<target-group-arn>", "Weight": 1}]
    }
  }]'
```

Then modify the listener rule to add the host header transform:

```
aws elbv2 modify-rule \
  --rule-arn <default-rule-arn> \
  --actions '[{
    "Type": "forward",
    "TargetGroupArn": "<target-group-arn>",
    "ForwardConfig": {
      "TargetGroups": [{"TargetGroupArn": "<target-group-arn>", "Weight": 1}]
    }
  }]' \
  --transforms '[{
    "Type": "host-header",
    "HostHeaderConfig": {
      "Values": ["my-server.my-company.internal"]
    }
  }]'
```

 **Step 5: Configure the private endpoint** 

Use the ALB DNS name as the `routingDomain` and the public cert domain as the target URL.

```
{
  ...
  "privateEndpoint": {
    "managedVpcResource": {
      "vpcIdentifier": "<vpc-id>",
      "subnetIds": ["<subnet-id-1>", "<subnet-id-2>"],
      "endpointIpAddressType": "IPV4",
      "routingDomain": "internal-my-alb-1234567890.us-west-2.elb.amazonaws.com"
    }
  },
  ...
}
```

The target URL in your target configuration should use `https://my-server.my-company.com` (the public cert domain), not the private domain.

## Service-linked role for VPC egress
<a name="lattice-vpc-egress-slr"></a>

When you create a gateway target with a managed private endpoint ( `managedVpcResource` ), AgentCore uses the `AWSServiceRoleForBedrockAgentCoreGatewayNetwork` service-linked role to create and manage VPC Lattice resource gateways in your account. This role is created automatically the first time you create a managed private endpoint target, provided your IAM principal has the required `iam:CreateServiceLinkedRole` permission.

The service-linked role has the following key characteristics:
+ It can only create and delete VPC Lattice resource gateways that are tagged with `BedrockAgentCoreGatewayManaged: true` . It cannot modify resource gateways that you create and manage yourself.
+ AgentCore reuses the same managed resource gateway for targets that share the same VPC, subnet, security group, and IP address type configuration. The resource gateway is deleted only when no gateway targets are using it.
+ Resource configurations for managed Lattice are created in the AgentCore service account, not in your account. You will not see them in your VPC Lattice console.

For the full policy document and instructions for creating, editing, and deleting this role, see [Gateway service-linked role](service-linked-roles.md#gateway-service-linked-role).

## Target status and troubleshooting
<a name="lattice-vpc-egress-target-status"></a>

After you create a resource with a private endpoint, the resource goes through a `CREATING` state while AgentCore sets up the VPC Lattice resources and establishes the service network association. You can monitor the status by calling the relevant Get API (for example, `GetGatewayTarget` ) and checking the `status` and `statusReasons` fields.

The following table describes common status values and their meanings:


| Status | Description | 
| --- | --- | 
|   `CREATING`   |  AgentCore is setting up VPC Lattice resources and establishing the service network association. This can take up to a few minutes.  | 
|   `READY`   |  The private endpoint is configured and the target is ready to receive requests.  | 
|   `FAILED`   |  Target creation failed. Check the `statusReasons` field for details. Common causes include missing IAM permissions or an invalid resource configuration identifier.  | 

The following table describes common issues and their solutions:


| Issue | Solution | 
| --- | --- | 
|  Target creation fails with an IAM permission error  |  Ensure your IAM principal has the `iam:CreateServiceLinkedRole` permission for `bedrock-agentcore.amazonaws.com` . For self-managed Lattice, ensure you have the required VPC Lattice permissions listed in [Prerequisites](#lattice-vpc-egress-self-managed-lattice-prereqs).  | 
|  Tool invocations fail with a connection error after target creation  |  Verify that the security groups associated with the resource gateway allow inbound traffic on the port used by your private resource. Also verify that the private resource is running and accessible from the specified subnets.  | 
|  Tool invocations fail with a TLS error  |  If your private resource uses a certificate issued by a private CA, ensure that the certificate’s Subject Alternative Name (SAN) matches the domain in your MCP endpoint or OpenAPI server URL. If using a routing domain, ensure the routing domain correctly forwards TLS to your private resource.  | 
|  Resource configuration not found (self-managed)  |  For cross-account scenarios, ensure the AWS RAM resource share has been accepted in the gateway owner account before creating the target.  | 

## Limitations and considerations
<a name="lattice-vpc-egress-limitations"></a>

Be aware of the following limitations during the public preview of VPC egress for AgentCore:
+  **Private DNS** : Amazon VPC Lattice requires publicly resolvable DNS for resource configurations. If your private endpoint uses a domain that is only resolvable within your VPC, you must use the `routingDomain` field with a publicly resolvable intermediate domain such as a VPCE domain or internal ALB DNS name.
+  **Cross-account** : Cross-account private connectivity requires the self-managed Lattice option. Managed Lattice does not support cross-account scenarios.
+  **DNS TTL configuration** : VPC Lattice uses IP-based routing. Ensure that DNS TTLs for your resource configuration domain are configured appropriately so that IP address changes during rolling deployments do not cause connectivity disruption.

# Configure Amazon Bedrock AgentCore Runtime and tools for VPC
<a name="agentcore-vpc"></a>

You can configure Amazon Bedrock AgentCore Runtime and built-in tools (Code Interpreter and Browser Tool) to connect to resources in your Amazon Virtual Private Cloud (VPC). By configuring VPC connectivity, you enable secure access to private resources such as databases, internal APIs, and services within your VPC.

## VPC connectivity for Amazon Bedrock AgentCore Runtime and tools
<a name="vpc-connectivity-agentcore"></a>

To enable Amazon Bedrock AgentCore Runtime and built-in tools to securely access resources in your private VPC, AgentCore provides VPC connectivity capabilities. This feature allows your runtime and tools to:
+ Connect to private resources without exposing them to the internet
+ Maintain secure communications within your organization’s network boundaries
+ Access enterprise data stores and internal services while preserving security

When you configure VPC connectivity for Amazon Bedrock AgentCore Runtime and tools:
+ Amazon Bedrock creates elastic network interfaces (ENIs) in your VPC using the service-linked role `AWSServiceRoleForBedrockAgentCoreNetwork` 
+ These ENIs enable your Amazon Bedrock AgentCore Runtime and tools to securely communicate with resources in your VPC
+ Each ENI is assigned a private IP address from the subnets you specify
+ Security groups attached to the ENIs control which resources your runtime and tools can communicate with

**Note**  
ENIs are shared resources across agents that use the same subnet and security group configuration. When you delete an agent, the associated ENI may persist in your VPC for up to 8 hours before it is automatically removed.

**Note**  
VPC connectivity impacts inbound and outbound network traffic from AgentCore services. When you host your application in an AWS VPC, you can establish private connectivity to the AgentCore Runtime and AgentCore Gateway APIs by adding the AgentCore VPC endpoint to your VPC. This enables secure API calls, without internet traversal, through VPC PrivateLink inbound connections.

## Prerequisites
<a name="agentcore-prerequisites"></a>

Before configuring Amazon Bedrock AgentCore Runtime and tools for VPC access, ensure you have:
+ An Amazon VPC with appropriate subnets for your runtime and tool requirements. For example, to configure your subnets to have internet access, see [Internet access considerations](#agentcore-internet-access).
+ Subnets located in supported Availability Zones for your region. For information about supported Availability Zones, see [Supported Availability Zones](#agentcore-supported-azs).
+ Appropriate security groups defined in your VPC for runtime and tool access patterns. For example, to configure your security groups to connect to Amazon RDS, see [Example: Connecting to an Amazon RDS database](#agentcore-security-groups-example).
+ Required IAM permissions to create and manage the service-linked role (already included in the AWS managed policy [BedrockAgentCoreFullAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/BedrockAgentCoreFullAccess.html) ). For information about required permissions, see [IAM permissions](#agentcore-iam-permissions).
+ Required VPC endpoints if your VPC doesn’t have internet access. For example, to configure your VPC endpoints, see [VPC endpoint configuration](#agentcore-vpc-endpoints).
+ Understanding of your runtime and tool network requirements (databases, APIs, web resources). If you need to use Browser tool which requires internet access, then your VPC should have internet access through NAT Gateway. For example, see [Security group considerations](#agentcore-security-groups).

**Important**  
AgentCore creates a network interface in your account with a private IP address. Using a public subnet does not provide internet connectivity. To enable internet access, place it in private subnets with a route to a NAT Gateway.

## Supported Availability Zones
<a name="agentcore-supported-azs"></a>

AgentCore supports VPC connectivity in specific Availability Zones within each supported region. When configuring subnets for your Amazon Bedrock AgentCore Runtime and built-in tools, ensure that your subnets are located in the supported Availability Zones for your region.

The following table shows the supported Availability Zone IDs for each region:


| Region | Region Code | Supported Availability Zones | 
| --- | --- | --- | 
|  US East (N. Virginia)  |  us-east-1  |  use1-az1 use1-az2 use1-az4  | 
|  US East (Ohio)  |  us-east-2  |  use2-az1 use2-az2 use2-az3  | 
|  US West (Oregon)  |  us-west-2  |  usw2-az1 usw2-az2 usw2-az3  | 
|  Asia Pacific (Sydney)  |  ap-southeast-2  |  apse2-az1 apse2-az2 apse2-az3  | 
|  Asia Pacific (Mumbai)  |  ap-south-1  |  aps1-az1 aps1-az2 aps1-az3  | 
|  Asia Pacific (Singapore)  |  ap-southeast-1  |  apse1-az1 apse1-az2 apse1-az3  | 
|  Asia Pacific (Tokyo)  |  ap-northeast-1  |  apne1-az1 apne1-az2 apne1-az4  | 
|  Europe (Ireland)  |  eu-west-1  |  euw1-az1 euw1-az2 euw1-az3  | 
|  Europe (Frankfurt)  |  eu-central-1  |  euc1-az1 euc1-az2 euc1-az3  | 
|  Europe (Stockholm)  |  eu-north-1  |  eun1-az1 eun1-az2 eun1-az3  | 
|  Europe (Paris)  |  eu-west-3  |  euw3-az1 euw3-az2 euw3-az3  | 
|  Asia Pacific (Seoul)  |  ap-northeast-2  |  apne2-az1 apne2-az2 apne2-az3  | 
|  Europe (London)  |  eu-west-2  |  euw2-az1 euw2-az2 euw2-az3  | 
|  Canada (Central)  |  ca-central-1  |  cac1-az1 cac1-az2 cac1-az4  | 

**Important**  
Subnets must be located in the supported Availability Zones listed above. If you specify subnets in unsupported Availability Zones, the configuration will fail during resource creation.

To identify the Availability Zone ID of your subnets, you can use the following CLI command:

```
aws ec2 describe-subnets --subnet-ids subnet-12345678 --query 'Subnets[0].AvailabilityZoneId'
```

## IAM permissions
<a name="agentcore-iam-permissions"></a>

AgentCore uses the service-linked role `AWSServiceRoleForBedrockAgentCoreNetwork` to create and manage network interfaces in your VPC. This role is automatically created when you first configure Amazon Bedrock AgentCore Runtime or AgentCore built-in tools to use VPC connectivity.

If you need to create this role manually, your IAM entity needs the following permissions:

```
{
    "Action": "iam:CreateServiceLinkedRole",
    "Effect": "Allow",
    "Resource": "arn:aws:iam::*:role/aws-service-role/network.bedrock-agentcore.amazonaws.com/AWSServiceRoleForBedrockAgentCoreNetwork",
    "Condition": {
        "StringLike": {
            "iam:AWSServiceName": "network.bedrock-agentcore.amazonaws.com"
        }
    }
}
```

This permission is already included in the AWS managed policy [BedrockAgentCoreFullAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/BedrockAgentCoreFullAccess.html).

## Best practices
<a name="agentcore-best-practices"></a>

For optimal performance and security with VPC-connected Amazon Bedrock AgentCore Runtime and built-in tools:
+  **High Availability** :
  + Configure at least two private subnets in different Availability Zones. For a list of supported Availability Zones, see [Supported Availability Zones](#agentcore-supported-azs).
  + Deploy dependent resources (such as databases or caches) with multi-AZ support to avoid single points of failure.
+  **Network Performance** :
  + Place Amazon Bedrock AgentCore Runtime or built-in tools subnets in the same Availability Zones as the resources they connect to. This reduces cross-AZ latency and data transfer costs.
  + Use VPC endpoints for AWS services whenever possible. Endpoints provide lower latency, higher reliability, and avoid NAT gateway charges for supported services.
+  **Security** :
  + Apply the principle of least privilege when creating security group rules.
  + Enable VPC Flow Logs for auditing and monitoring. Review logs regularly to identify unexpected traffic patterns.
+  **Internet Access** :
  + To provide internet access from Amazon Bedrock AgentCore Runtime or built-in tools inside a VPC, configure a NAT gateway in a public subnet. Update the route table for private subnets to send outbound traffic (0.0.0.0/0) to the NAT gateway.
  + We recommend using VPC endpoints for AWS services instead of internet routing to improve security and reduce costs.

## Configuring VPC access for runtime and tools
<a name="agentcore-configuration"></a>

You can configure VPC access for Amazon Bedrock AgentCore Runtime and built-in tools using the AWS Management Console, AWS CLI, or AWS SDKs.

### Runtime configuration
<a name="runtime-config"></a>

**Example**  

1. Open the AgentCore console at [https://console.aws.amazon.com/bedrock-agentcore/home\$1](https://console.aws.amazon.com/bedrock-agentcore/home#).

1. Navigate to the AgentCore section

1. Select or create an Amazon Bedrock AgentCore Runtime configuration

1. Choose your ECR image

1. Under the Network configuration section, choose **VPC** 

1. Select your VPC from the dropdown list

1. Select the appropriate subnets for your application needs

1. Select one or more security groups to apply to the ENIs

1. Save your configuration

1. 

   ```
   aws bedrock-agentcore-control create-agent-runtime \
     --agent-runtime-name "MyAgentRuntime" \
     --network-configuration '{
         "networkMode": "VPC",
         "networkModeConfig": {
           "subnets": ["subnet-0123456789abcdef0", "subnet-0123456789abcdef1"],
           "securityGroups": ["sg-0123456789abcdef0"]
         }
       }'
   ```

1. 

   ```
   import boto3
   
   client = boto3.client('bedrock-agentcore')
   
   response = client.create_runtime(
       runtimeName='MyAgentRuntime',
       networkConfiguration={
           'networkMode': 'VPC',
           'networkModeConfig': {
               'subnets': ['subnet-0123456789abcdef0', 'subnet-0123456789abcdef1'],
               'securityGroups': ['sg-0123456789abcdef0']
           }
       },
       lifecycleConfiguration={
           'idleRuntimeSessionTimeout': 300,  # 5 min, configurable
           'maxLifetime': 1800                # 30 minutes, configurable
       },
   )
   ```

### Code Interpreter configuration
<a name="code-interpreter-config"></a>

**Example**  

1. Open the AgentCore console at [https://console.aws.amazon.com/bedrock-agentcore/home\$1](https://console.aws.amazon.com/bedrock-agentcore/home#).

1. Navigate to AgentCore → Built-in Tools → Code Interpreter

1. Select **Create Code Interpreter** or modify existing configuration

1. Provide a tool name (optional)

1. Configure execution role with necessary permissions

1. Under Network configuration, choose **VPC** 

1. Select your VPC from the dropdown

1. Choose appropriate subnets (recommend private subnets across multiple AZs with NAT gateway)

1. Select security groups for ENI access control

1. Configure execution role with necessary permissions

1. Save your configuration

1. 

   ```
   aws bedrock-agentcore-control create-code-interpreter \
     --region <Region> \
     --name "my-code-interpreter" \
     --description "My Code Interpreter with VPC mode for data analysis" \
     --execution-role-arn "arn:aws:iam::123456789012:role/my-execution-role" \
     --network-configuration '{
       "networkMode": "VPC",
       "networkModeConfig": {
         "subnets": ["subnet-0123456789abcdef0", "subnet-0123456789abcdef1"],
         "securityGroups": ["sg-0123456789abcdef0"]
       }
     }'
   ```

1. 

   ```
   import boto3
   
   # Initialize the boto3 client
   cp_client = boto3.client(
       'bedrock-agentcore-control',
       region_name="<Region>",
       endpoint_url="https://bedrock-agentcore-control.<Region>.amazonaws.com"
   )
   
   # Create a Code Interpreter
   response = cp_client.create_code_interpreter(
       name="myTestVpcCodeInterpreter",
       description="Test code sandbox for development",
       executionRoleArn="arn:aws:iam::123456789012:role/my-execution-role",
       networkConfiguration={
           'networkMode': 'VPC',
           'networkModeConfig': {
               'subnets': ['subnet-0123456789abcdef0', 'subnet-0123456789abcdef1'],
               'securityGroups': ['sg-0123456789abcdef0']
           }
       }
   )
   
   # Print the Code Interpreter ID
   code_interpreter_id = response["codeInterpreterId"]
   print(f"Code Interpreter ID: {code_interpreter_id}")
   ```

### Browser Tool configuration
<a name="browser-tool-config"></a>

**Example**  

1. Open the AgentCore console at [https://console.aws.amazon.com/bedrock-agentcore/home\$1](https://console.aws.amazon.com/bedrock-agentcore/home#).

1. In the navigation pane, choose **Built-in tools** 

1. Choose **Create Browser tool** 

1. Provide a tool name (optional) and description (optional)

1. Set execution role permissions

1. Under the Network configuration section, choose **VPC** mode

1. Select your VPC and subnets

1. Configure security groups for web access requirements

1. Set execution role permissions

1. Save your configuration

1. 

   ```
   aws bedrock-agentcore-control create-browser \
     --region <Region> \
     --name "my-browser" \
     --description "My browser for web interaction" \
     --network-configuration '{
       "networkMode": "VPC",
       "networkModeConfig": {
         "subnets": ["subnet-0123456789abcdef0", "subnet-0123456789abcdef1"],
         "securityGroups": ["sg-0123456789abcdef0"]
       }
     }' \
     --recording '{
       "enabled": true,
       "s3Location": {
         "bucket": "my-bucket-name",
         "prefix": "sessionreplay"
       }
     }' \
     --execution-role-arn "arn:aws:iam::123456789012:role/my-execution-role"
   ```

1. 

   ```
   import boto3
   
   # Initialize the boto3 client
   cp_client = boto3.client(
       'bedrock-agentcore-control',
       region_name="<Region>",
       endpoint_url="https://bedrock-agentcore-control.<Region>.amazonaws.com"
   )
   
   # Create a Browser
   response = cp_client.create_browser(
       name="myTestVpcBrowser",
       description="Test browser with VPC mode for development",
       networkConfiguration={
           'networkMode': 'VPC',
           'networkModeConfig': {
               'subnets': ['subnet-0123456789abcdef0', 'subnet-0123456789abcdef1'],
               'securityGroups': ['sg-0123456789abcdef0']
           }
       },
       executionRoleArn="arn:aws:iam::123456789012:role/Sessionreplay",
       recording={
           "enabled": True,
           "s3Location": {
               "bucket": "session-record-123456789012",
               "prefix": "replay-data"
           }
       }
   )
   ```

## Security group considerations
<a name="agentcore-security-groups"></a>

Security groups act as virtual firewalls for your Amazon Bedrock AgentCore Runtime or built-in tool when connected to a VPC. They control inbound and outbound traffic at the instance level. To configure security groups for your runtime:
+  **Outbound rules** – Define outbound rules to allow your Amazon Bedrock AgentCore Runtime to connect to required VPC resources.
+  **Inbound rules** – Ensure that the target resource’s security group allows inbound connections from the security group associated with your Amazon Bedrock AgentCore Runtime.
+  **Least privilege** – Apply the principle of least privilege by allowing only the minimum required traffic.

### Example: Connecting to an Amazon RDS database
<a name="agentcore-security-groups-example"></a>

When your Amazon Bedrock AgentCore Runtime connects to an Amazon RDS database, configure the security groups as follows:

 **Amazon Bedrock AgentCore Runtime security group** 
+  **Outbound** – Allow TCP traffic to the RDS database’s security group on port 3306 (MySQL).
+  **Inbound** – Not required. The runtime only initiates outbound connections.

 **Amazon RDS database security group** 
+  **Inbound** – Allow TCP traffic from the Amazon Bedrock AgentCore Runtime security group on port 3306.
+  **Outbound** – Not required. Return traffic is automatically allowed because security groups are stateful.

## VPC endpoint configuration
<a name="agentcore-vpc-endpoints"></a>

When running Amazon Bedrock AgentCore Runtime in a VPC, we strongly recommend configuring the following VPC endpoints. These endpoints are **required** if your VPC does not have internet access, and **strongly recommended** even if your VPC has a NAT gateway, to avoid NAT gateway data processing charges.

### Required VPC endpoints
<a name="agentcore-required-endpoints"></a>
+  **Amazon ECR Requirements** :
  + Docker endpoint: `com.amazonaws.region.ecr.dkr` 
  + ECR API endpoint: `com.amazonaws.region.ecr.api` 
+  **Amazon S3 Requirements** :
  + Gateway endpoint for ECR docker layer storage: `com.amazonaws.region.s3` 
**Important**  
For container agents, AgentCore periodically refreshes your container image from ECR, which stores image layers in Amazon S3. Without an S3 Gateway VPC Endpoint, this traffic routes through your NAT gateway and incurs data processing charges. An S3 Gateway VPC Endpoint is free and eliminates these charges. We strongly recommend adding this endpoint for all VPC-mode container agents, even if your VPC has internet access via NAT.
+  **CloudWatch Requirements** :
  + Logs endpoint: `com.amazonaws.region.logs` 

**Note**  
Be sure to replace *region* with your specific region if different.

**Note**  
If you are using [Persist session state across stop/resume with a filesystem configuration (Preview)](runtime-persistent-filesystems.md) , ensure your VPC meets the [Networking requirements](runtime-persistent-filesystems.md#session-storage-networking).

### Internet access considerations
<a name="agentcore-internet-access"></a>

When you connect Amazon Bedrock AgentCore Runtime or a built-in tool to a Virtual Private Cloud (VPC), it does not have internet access by default. By default, these resources can communicate only with resources inside the same VPC. If your runtime or tool requires access to both VPC resources and the internet, you must configure your VPC accordingly.

#### Internet access architecture
<a name="agentcore-internet-architecture"></a>

To enable internet access for your VPC-connected Amazon Bedrock AgentCore Runtime or built-in tool, configure your VPC with the following components:
+  **Private subnets** – Place the Amazon Bedrock AgentCore Runtime or tool’s network interfaces in private subnets.
+  **Public subnets with a NAT gateway** – Deploy a NAT gateway in one or more public subnets to provide outbound internet access for private resources.
+  **Internet gateway (IGW)** – Attach an internet gateway to your VPC to enable communication between the NAT gateway and the internet.

#### Routing configuration
<a name="agentcore-routing-configuration"></a>

Update your subnet route tables as follows:
+  **Private subnet route table** – Add a default route (0.0.0.0/0) that points to the NAT gateway. This allows outbound traffic from the runtime or tool to reach the internet.
+  **Public subnet route table** – Add a default route (0.0.0.0/0) that points to the internet gateway. This allows the NAT gateway to communicate with the internet.

**Important**  
Connecting Amazon Bedrock AgentCore Runtime and built-in tools to public subnets does not provide internet access. Always use private subnets with NAT gateways for internet connectivity.

## Monitoring and troubleshooting
<a name="agentcore-monitoring"></a>

To monitor and troubleshoot your VPC-connected Amazon Bedrock AgentCore Runtime and tools:

### CloudWatch Logs
<a name="agentcore-cloudwatch-logs"></a>

Enable CloudWatch Logs for your Amazon Bedrock AgentCore Runtime to identify any connectivity issues:
+ Check error messages related to VPC connectivity
+ Look for timeout errors when connecting to VPC resources
+ Monitor initialization times (VPC connectivity may increase session startup times)

### Common issues and solutions
<a name="agentcore-common-issues"></a>
+  **Connection timeouts** :
  + Verify security group rules are correct
  + Ensure route tables are properly configured
  + Check that the target resource is running and accepting connections
+  **DNS resolution failures** :
  + Ensure that DNS resolution is enabled in your VPC
  + Verify that your DHCP options are configured correctly
+  **Missing ENIs** :
  + Check the IAM permissions to ensure the service-linked role has appropriate permissions
  + Look for any service quotas that may have been reached

### Code Interpreter issues
<a name="code-interpreter-issues"></a>
+  **Code Interpreter invoke call timeouts when trying to call a public endpoint** :
  + Verify that VPC is configured with NAT gateway for internet access
+  **Invoke calls for a Code Interpreter with private VPC endpoints throw "AccessDenied" errors** :
  + Make sure the execution role passed during Code Interpreter creation has the right permissions for AWS service for which VPC endpoint was configured
+  **Invoke calls for a Code Interpreter with some private VPC endpoints show "Unable to locate Credentials" error** :
  + Check that the execution role has been provided while creating the code interpreter

### Browser Tool issues
<a name="browser-tool-issues"></a>
+  **Live-View/Connection Stream is unable to load webpages and fails with connection timeouts** :
  + Check if the browser was created with Private Subnet with NAT Gateway

### Testing VPC connectivity
<a name="testing-connectivity"></a>

To verify that your AgentCore Runtime and tools have proper VPC connectivity, you can test connections to your private resources and verify that network interfaces are created correctly in your specified subnets.

To verify that your AgentCore tool has internet access, you can configure a Code Interpreter with your VPC configuration and use the `Invoke` API with `executeCommand` that attempts to connect to a public API or website using `curl` command and check the response. If the connection times out, review your VPC configuration, particularly your route tables and NAT gateway setup.

```
# Using awscurl
awscurl -X POST \
  "https://bedrock-agentcore.<Region>.amazonaws.com/code-interpreters/<code_interpreter_id>/tools/invoke" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "x-amzn-code-interpreter-session-id: your-session-id" \
  --service bedrock-agentcore \
  --region <Region> \
  -d '{
    "name": "executeCommand",
    "arguments": {
      "command": "curl amazon.com"
    }
  }'
```

# Use IAM condition keys with AgentCore Runtime and built-in tools VPC settings
<a name="security-vpc-condition"></a>

Use AgentCore-specific condition keys for VPC settings to provide additional permission controls for your AgentCore Runtime and built-in tools. For example, require that all runtimes in your organization are connected to a VPC. Specify the subnets and security groups that AgentCore Runtime users can and cannot use.

AgentCore supports the following condition keys in IAM policies:
+  **bedrock-agentcore:subnets** – Allow or deny one or more subnets.
+  **bedrock-agentcore:securityGroups** – Allow or deny one or more security groups.

The AgentCore Control Plane API operations `CreateAgentRuntime` , `UpdateAgentRuntime` , `CreateCodeInterpreter` , and `CreateBrowser` support these condition keys. For more information about using condition keys in IAM policies, see [IAM JSON Policy Elements: Condition](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html) in the IAM User Guide.

## Example policies with condition keys for VPC settings
<a name="example-policies-vpc-condition"></a>

The following examples demonstrate how to use condition keys for VPC settings. Create a policy statement with the desired restrictions, then attach the policy statement to the target user or role.

### Require that users deploy only VPC-connected runtimes and tools
<a name="require-vpc-connected-runtimes"></a>

To require that all users deploy only VPC-connected AgentCore Runtime and built-in tools, deny runtime and tool create and update operations that don’t include valid subnets and security groups.

```
{
    "Sid": "EnforceVPCRuntime",
    "Action": [
        "bedrock-agentcore:CreateAgentRuntime",
        "bedrock-agentcore:UpdateAgentRuntime",
        "bedrock-agentcore:CreateCodeInterpreter",
        "bedrock-agentcore:CreateBrowser"
    ],
    "Effect": "Deny",
    "Resource": "*",
    "Condition": {
        "Null": {
            "bedrock-agentcore:subnets": "true",
            "bedrock-agentcore:securityGroups": "true"
        }
    }
}
```

### Enforce that users use only specific subnets and security groups
<a name="enforce-specific-subnets-security-groups"></a>

To enforce that users use only specific approved subnets and security groups, use the `ForAnyValue` set operator with `StringNotEquals` . The condition returns true if any one of the context key values in the request does not match the context key values in the policy, denying requests that include any unapproved values. The following example enforces that users can only use `subnet-0123456789abcdef0` and `subnet-0123456789abcdef1` for subnets, and `sg-0123456789abcdef0` and `sg-0123456789abcdef1` for security groups.

```
[
  {
    "Sid": "DenyIfNotSpecificSubnets",
    "Effect": "Deny",
    "Action": [
      "bedrock-agentcore:CreateAgentRuntime",
      "bedrock-agentcore:UpdateAgentRuntime",
      "bedrock-agentcore:CreateCodeInterpreter",
      "bedrock-agentcore:CreateBrowser"
    ],
    "Resource": "*",
    "Condition": {
      "ForAnyValue:StringNotEquals": {
        "bedrock-agentcore:subnets": ["subnet-0123456789abcdef0", "subnet-0123456789abcdef1"]
      }
    }
  },
  {
    "Sid": "DenyIfNotSpecificSecurityGroups",
    "Effect": "Deny",
    "Action": [
      "bedrock-agentcore:CreateAgentRuntime",
      "bedrock-agentcore:UpdateAgentRuntime",
      "bedrock-agentcore:CreateCodeInterpreter",
      "bedrock-agentcore:CreateBrowser"
    ],
    "Resource": "*",
    "Condition": {
      "ForAnyValue:StringNotEquals": {
        "bedrock-agentcore:securityGroups": ["sg-0123456789abcdef0", "sg-0123456789abcdef1"]
      }
    }
  }
]
```

### Deny users access to specific subnets or security groups
<a name="deny-specific-subnets-security-groups"></a>

To deny users access to specific subnets and security groups, use the `ForAnyValue` set operator with `StringEquals` . The condition returns true if any one of the context key values in the request matches any one of the context key values in the policy. The following example denies users access to `subnet-0123456789abcdef0` and `subnet-0123456789abcdef1` for subnets, and `sg-0123456789abcdef0` and `sg-0123456789abcdef1` for security groups.

```
[
  {
    "Sid": "EnforceOutOfSubnet",
    "Action": [
      "bedrock-agentcore:CreateAgentRuntime",
      "bedrock-agentcore:UpdateAgentRuntime",
      "bedrock-agentcore:CreateCodeInterpreter",
      "bedrock-agentcore:CreateBrowser"
    ],
    "Effect": "Deny",
    "Resource": "*",
    "Condition": {
      "ForAnyValue:StringEquals": {
        "bedrock-agentcore:subnets": ["subnet-0123456789abcdef0", "subnet-0123456789abcdef1"]
      }
    }
  },
  {
    "Sid": "EnforceOutOfSecurityGroups",
    "Action": [
      "bedrock-agentcore:CreateAgentRuntime",
      "bedrock-agentcore:UpdateAgentRuntime",
      "bedrock-agentcore:CreateCodeInterpreter",
      "bedrock-agentcore:CreateBrowser"
    ],
    "Effect": "Deny",
    "Resource": "*",
    "Condition": {
      "ForAnyValue:StringEquals": {
        "bedrock-agentcore:securityGroups": ["sg-0123456789abcdef0", "sg-0123456789abcdef1"]
      }
    }
  }
]
```