Reach services in your AWS VPC over VPC peering

Peer a new Agent Gateway appliance with a VPC in your AWS account, then route traffic so surfaces reach your MCP servers, agents, and APIs by private IP address.

This guide peers a new Agent Gateway appliance with a virtual private cloud (VPC) in your AWS account, so the gateway reaches your services there by their private IP addresses. For background, see Maintain network isolation with VPC peering.

Without peering, every service a surface forwards to needs an address the gateway can reach over the internet. Peering gives the gateway a private network path to your VPC, so your MCP servers, agents, and internal APIs keep no public endpoint.

Use this guide when:

  • The managed agents, MCP servers, or APIs your surfaces call run in an AWS VPC.
  • Your security or compliance rules require traffic between the gateway and those services to stay off the public internet.

You set up peering when you create the appliance configuration, and the peering details are fixed after that. To add peering to a gateway you already run, you create a new gateway with these steps and move to it, as described in Change or remove peering.

Prerequisites

  • An Affinidi Portal account with permission to create Agent Gateway configurations.
  • An appliance size other than Basic. Portal offers VPC peering only on larger sizes.
  • In the AWS account that owns the VPC, permission to create IAM roles and to edit route tables and security groups.
  • Your VPC’s ID, its IPv4 CIDR block, and its AWS region.
  • A VPC CIDR block that doesn’t overlap the appliance’s network, because AWS peers only VPCs with distinct address ranges. Ask Affinidi support for the appliance’s address range along with the account ID below.
  • A VPC that no other Agent Gateway appliance peers with. Every peered appliance uses the same address range, so a route table in your VPC can send that range to one appliance only. The one exception is while you move to a new configuration, as described in Change or remove peering. Each configuration also peers with one VPC: to reach several VPCs, create a configuration for each.
  • The AWS account ID that Affinidi uses to set up peering connections. Ask Affinidi support for it.

Steps

Create the peering role in your AWS account

In the AWS account that owns the VPC, create an AWS Identity and Access Management (IAM) role that Affinidi’s account can assume. Use this trust policy, replacing <AFFINIDI_ACCOUNT_ID> with the account ID from Affinidi support:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": { "AWS": "arn:aws:iam::<AFFINIDI_ACCOUNT_ID>:root" },
      "Action": "sts:AssumeRole"
    }
  ]
}

Attach a permissions policy that lets the role accept peering connections into this VPC only. Replace <REGION>, <YOUR_ACCOUNT_ID>, and <VPC_ID> with your VPC’s region, your account ID, and the VPC’s ID:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "ec2:AcceptVpcPeeringConnection",
      "Resource": "arn:aws:ec2:<REGION>:<YOUR_ACCOUNT_ID>:vpc/<VPC_ID>"
    },
    {
      "Effect": "Allow",
      "Action": "ec2:AcceptVpcPeeringConnection",
      "Resource": "arn:aws:ec2:<REGION>:<YOUR_ACCOUNT_ID>:vpc-peering-connection/*",
      "Condition": {
        "ArnEquals": {
          "ec2:AccepterVpc": "arn:aws:ec2:<REGION>:<YOUR_ACCOUNT_ID>:vpc/<VPC_ID>"
        }
      }
    }
  ]
}

Copy the role’s ARN, for example arn:aws:iam::123456789012:role/agent-gateway-peering.

The role lets a peering connection into your VPC. Your route tables and security groups, which you set in steps 5 and 6, decide which of your services the appliance can reach.

Start a configuration in Affinidi Portal

  1. In Affinidi Portal, open Agent Gateway and select Create configuration.
  2. Under Configuration details, enter a Name of configuration and, optionally, a description.
  3. In Appliance size, select a size other than Basic.
  4. Select Next step.

Enter the VPC peering details

In VPC Peering Details (optional), set VPC Peering to Enable and fill in the fields:

FieldValue
Peer VPC IDYour VPC’s ID, for example vpc-0123456789abcdef0.
Peer CIDR blockYour VPC’s IPv4 CIDR block, for example 10.0.0.0/16. The appliance routes this range through the peering connection.
Peer AWS account IDThe 12-digit ID of the AWS account that owns the VPC.
Cross Account Role ARNThe ARN of the role you created in step 1.
Peer regionThe AWS region your VPC is in.

Next step becomes available once every field is filled in. Select it.

Create the configuration

Under Review, check the details and select Create configuration. Wait until the configuration’s deployment state shows Complete. The configuration’s details then list the peering fields you entered.

Route the appliance’s traffic in your VPC

  1. In the AWS console for your account, switch to your VPC’s region, open VPC › Peering connections, and find the active connection whose accepter VPC is yours.
  2. Note its ID, such as pcx-0a1b2c3d4e5f67890, and its requester CIDR block: the address range of the appliance’s network.
  3. In the route table of each subnet where your services run, add a route whose destination is the requester CIDR block and whose target is the peering connection.
  4. Optional: if the gateway calls an EC2 instance by the public DNS hostname AWS gave it, open the connection’s DNS settings and let the requester VPC resolve your VPC’s hostnames to private IP addresses. This setting also needs DNS resolution and DNS hostnames turned on in your VPC. An internal load balancer’s DNS name already resolves to private addresses, so it works without this setting.

Affinidi has already added the route to your Peer CIDR block on the appliance’s side.

Allow the gateway in your security groups

In the security group of each service the gateway calls, add an inbound rule for the service’s port with the appliance’s requester CIDR block as the source. Use the whole block, because the gateway’s private IP addresses change when it restarts. If your subnets use network ACLs, allow the same traffic there, in both directions.

Point a surface at a private address

  1. In the Agent Gateway dashboard, open the surface on the canvas and select its Managed Agent node.
  2. In Endpoint Type, select Direct URL.
  3. In Target Endpoint URL, enter the service’s private address, for example http://10.0.1.12:8080/mcp, or the DNS name of an internal load balancer in your VPC.
  4. Select the save icon (tooltip: Save changes) on the canvas.

A Transit Point’s destination accepts a private address in the same way.

Confirm

Test 1: peering connection lookup returns an active connection

aws ec2 describe-vpc-peering-connections --region <REGION> \
  --filters Name=accepter-vpc-info.vpc-id,Values=<VPC_ID> \
  --query 'VpcPeeringConnections[].{Id:VpcPeeringConnectionId,Status:Status.Code,ApplianceCidr:RequesterVpcInfo.CidrBlock}'

Expected: one connection with "Status": "active" and the appliance’s CIDR block.

Test 2: request through the surface returns the private service’s response

Send a request to the surface’s Entry point URL as one of its callers, with the credential its Caller Context requires.

Expected: the response of the service at the private address. On the surface’s Monitoring tab, the request appears with a successful status.

Change or remove peering

The peering details are fixed once the configuration is created. Updates that leave them alone, such as a version upgrade, keep the existing peering connection.

To peer with a different VPC, use a different role or region, or add or remove peering, you move to a new configuration. A new configuration is a new gateway: it has its own domain and Entry point URLs, and it starts with no surfaces, identities, or users. A backup restores only onto the gateway it was taken from, so you set the new gateway up again.

  1. Create the new configuration. To peer, follow the steps above. To remove peering, set VPC Peering to Disable in VPC Peering Details (optional).
  2. Set up the new gateway’s surfaces, identities, and users, and give your callers its Entry point URLs.
  3. If the new configuration peers with the same VPC, change the target of your routes to the appliance’s range from the old peering connection to the new one. The old gateway loses its path to your VPC at that moment. The security group rules from step 6 stay as they are, because the range is the same. If it peers with a different VPC, follow steps 5 and 6 in that VPC.
  4. Once your callers use the new gateway, delete the old configuration in Affinidi Portal.

Deleting a configuration also deletes its peering connection. Any route that still targets it then shows the state blackhole: remove it, together with security group rules the new gateway doesn’t use. Keep the IAM role from step 1 while any Agent Gateway appliance still peers with your VPC.

Troubleshooting

SymptomLikely causeFix
The peering connection is missing from VPC › Peering connections.The console shows a different region.Switch to your VPC’s region.
Next step stays unavailable in VPC Peering Details (optional).A field is empty.Fill in every field.
Selecting Next step shows an error under a field.The value doesn’t match the field’s format, such as a VPC ID without the vpc- prefix.Correct the value in the format the error names.
The deployment state shows Failed.The role’s trust policy names a different account, the role can’t accept the connection, the CIDR blocks overlap, or a peering detail is wrong.Check the role and the details, then contact Affinidi support with the configuration name. Because the peering details are fixed, correct them in a new configuration.
The peering connection is active, but requests to the surface time out or return 502.Your route table has no route to the appliance’s CIDR block, or a security group or network ACL blocks the gateway.Add the route from step 5 to the route table of the service’s subnet, and the inbound rule from step 6.
Saving the surface is refused for the Target Endpoint URL.The address is a cloud metadata endpoint, which the gateway always blocks.Use the service’s own private IP address.
Your routes to the appliance’s range show the state blackhole.The peering connection was deleted, usually with its configuration.Remove the routes, or point them at a new connection, as in Change or remove peering.

Next steps