Guide · AWS VPC Lattice · Service Networks

VPC Lattice Service Networks for MCP Servers — VPC Associations, Security Groups, and RAM Sharing

A VPC Lattice service network is the shared fabric that connects your MCP server VPCs to backend service VPCs. Getting service network configuration right — especially security groups and the managed prefix list — is what separates working connectivity from an infuriatingly silent 503. This guide covers creating and managing service networks, the security group rules that actually matter, the two-sided association model, monitoring association health, and sharing a service network across AWS accounts with Resource Access Manager.

TL;DR

A service network needs two associations to route traffic: a VPC association (which VPCs can reach services — requires a security group allowing outbound to the VPC Lattice managed prefix list) and a service association (which services appear in the network). After both associations reach ACTIVE, DNS resolves and traffic flows. The most common failure mode is the security group: the outbound rule on the VPC association SG must allow TCP 80 and 443 to pl-xxxxxxxx (the com.amazonaws.{region}.vpc-lattice managed prefix list), and the inbound rule on the target SG must allow TCP from the same prefix list.

Service network lifecycle and naming

Service network names must be 3–63 characters, only lowercase letters, digits, and hyphens, and unique in the account+region. The name is immutable after creation — to rename you must delete and recreate (which breaks all existing associations). Plan names carefully.

import {
  VpcLatticeClient,
  CreateServiceNetworkCommand,
  GetServiceNetworkCommand,
  UpdateServiceNetworkCommand,
  DeleteServiceNetworkCommand,
} from "@aws-sdk/client-vpc-lattice";

const lattice = new VpcLatticeClient({ region: "us-east-1" });

// Create — authType defaults to NONE if omitted
const network = await lattice.send(new CreateServiceNetworkCommand({
  name: "mcp-platform-prod",
  authType: "AWS_IAM",
  tags: {
    Environment: "production",
    ManagedBy: "platform-team",
  },
}));
// network.id: "sn-0abc123def456789a"
// network.arn: "arn:aws:vpc-lattice:us-east-1:123456789012:servicenetwork/sn-0abc123def456789a"
// network.status: "ACTIVE" (usually immediate)

// Update auth type only — name and ID cannot change
await lattice.send(new UpdateServiceNetworkCommand({
  serviceNetworkIdentifier: network.id,
  authType: "NONE",   // remove IAM auth requirement
}));

// Delete — must remove all associations first
await lattice.send(new DeleteServiceNetworkCommand({
  serviceNetworkIdentifier: network.id,
}));
// Throws ConflictException if associations exist

The VPC Lattice managed prefix list

VPC Lattice uses a managed prefix list that covers all Lattice ingress/egress CIDR ranges in a region. You reference this prefix list in security group rules instead of hardcoding CIDRs. The list is maintained by AWS and updated transparently when Lattice expands capacity.

# Retrieve the prefix list ID for your region
aws ec2 describe-managed-prefix-lists \
  --region us-east-1 \
  --filters "Name=prefix-list-name,Values=com.amazonaws.us-east-1.vpc-lattice" \
  --query "PrefixLists[0].PrefixListId" \
  --output text
# pl-0abc123def456789a

# IPv6 equivalent (if your VPCs use dual-stack):
aws ec2 describe-managed-prefix-lists \
  --region us-east-1 \
  --filters "Name=prefix-list-name,Values=com.amazonaws.us-east-1.ipv6.vpc-lattice" \
  --query "PrefixLists[0].PrefixListId" \
  --output text
# pl-0xyz789ghi012345b

In CDK or CloudFormation, reference the prefix list by name via a lookup rather than hardcoding the ID, since IDs differ per account and region.

Security group configuration

Security groups for VPC Lattice work in two locations: on the VPC association (controls outbound from the VPC into Lattice) and on the backend resources (controls inbound from Lattice to your targets). The rules are symmetric.

VPC association security group (caller side)

The security group you pass to CreateServiceNetworkVpcAssociationCommand controls what traffic the VPC is allowed to send into the Lattice fabric:

# CDK example for the VPC association security group
const latticeClientSg = new ec2.SecurityGroup(this, "LatticeClientSg", {
  vpc: mcpServerVpc,
  description: "Allows outbound to VPC Lattice",
  allowAllOutbound: false,
});

// Allow outbound HTTP to Lattice prefix list
latticeClientSg.addEgressRule(
  ec2.Peer.prefixList("pl-0abc123def456789a"),
  ec2.Port.tcp(80),
  "VPC Lattice HTTP"
);

// Allow outbound HTTPS to Lattice prefix list
latticeClientSg.addEgressRule(
  ec2.Peer.prefixList("pl-0abc123def456789a"),
  ec2.Port.tcp(443),
  "VPC Lattice HTTPS"
);

// IPv6 (if applicable)
latticeClientSg.addEgressRule(
  ec2.Peer.prefixList("pl-0xyz789ghi012345b"),
  ec2.Port.tcp(443),
  "VPC Lattice HTTPS IPv6"
);

Target security group (backend side)

Your ECS tasks, EC2 instances, or ALBs need an inbound rule from the same prefix list:

const backendSg = new ec2.SecurityGroup(this, "BackendSg", {
  vpc: serviceVpc,
  description: "Allows inbound from VPC Lattice",
});

// Allow inbound from Lattice on the backend service port
backendSg.addIngressRule(
  ec2.Peer.prefixList("pl-0abc123def456789a"),
  ec2.Port.tcp(3000),
  "VPC Lattice inbound to service port"
);

Missing either of these rules produces connection failures that show up as 503 Service Unavailable responses or health check failures — not IAM errors. If traffic is not flowing, check the security group rules on both sides before looking at auth policies.

Creating a VPC association

A VPC association registers a VPC as a consumer of the service network. All EC2 instances, ECS tasks, and Lambda functions in the VPC can then resolve and call services in the network.

import {
  CreateServiceNetworkVpcAssociationCommand,
  GetServiceNetworkVpcAssociationCommand,
  ListServiceNetworkVpcAssociationsCommand,
  DeleteServiceNetworkVpcAssociationCommand,
} from "@aws-sdk/client-vpc-lattice";

const vpcAssoc = await lattice.send(new CreateServiceNetworkVpcAssociationCommand({
  serviceNetworkIdentifier: "sn-0abc123def456789a",
  vpcIdentifier: "vpc-0mcp1server2vpc34",
  securityGroupIds: ["sg-0abc123outbound"],
}));
console.log("Association ID:", vpcAssoc.id);
// sna-0abc123def456789a

// Poll until ACTIVE (usually < 10 seconds)
let assocStatus = vpcAssoc.status;
while (assocStatus !== "ACTIVE" && assocStatus !== "CREATE_FAILED") {
  await new Promise(r => setTimeout(r, 2000));
  const detail = await lattice.send(new GetServiceNetworkVpcAssociationCommand({
    serviceNetworkVpcAssociationIdentifier: vpcAssoc.id,
  }));
  assocStatus = detail.status;
}
if (assocStatus === "CREATE_FAILED") {
  throw new Error("VPC association failed — check security group configuration");
}

Key status values:

StatusMeaning
CREATE_IN_PROGRESSLattice is propagating the association
ACTIVEDNS resolution active; traffic can flow
CREATE_FAILEDAssociation failed — check security groups and VPC CIDR conflicts
DELETE_IN_PROGRESSDisassociation in progress
DELETE_FAILEDDisassociation failed — retry

Updating an existing VPC association's security groups is done via UpdateServiceNetworkVpcAssociationCommand. You cannot change the VPC ID of an existing association — delete and recreate.

Creating a service association

A service association makes a service discoverable within a service network. Services and service networks can be in different AWS accounts — Lattice uses RAM to authorize cross-account associations. Within the same account, the association is straightforward:

import {
  CreateServiceNetworkServiceAssociationCommand,
  GetServiceNetworkServiceAssociationCommand,
} from "@aws-sdk/client-vpc-lattice";

const svcAssoc = await lattice.send(new CreateServiceNetworkServiceAssociationCommand({
  serviceNetworkIdentifier: "sn-0abc123def456789a",
  serviceIdentifier: "svc-0xyz789ghi012345b",
}));
console.log("Service association ID:", svcAssoc.id);
// sns-0abc123def456789a

// DNS name appears in the association response
console.log("DNS name:", svcAssoc.dnsEntry?.domainName);
// mcp-data-service-0a1b2c.mcp-platform-3d4e5f.vpc-lattice-svcs.us-east-1.on.aws

// Poll until ACTIVE
let status = svcAssoc.status;
while (status === "CREATE_IN_PROGRESS") {
  await new Promise(r => setTimeout(r, 2000));
  const detail = await lattice.send(new GetServiceNetworkServiceAssociationCommand({
    serviceNetworkServiceAssociationIdentifier: svcAssoc.id,
  }));
  status = detail.status;
  if (status === "CREATE_FAILED") {
    throw new Error(`Service association failed: ${detail.failureCode} — ${detail.failureMessage}`);
  }
}

Common failure codes on CREATE_FAILED: SERVICE_NOT_FOUND (wrong service ID), SERVICE_NETWORK_NOT_FOUND (wrong network ID), RESOURCE_SHARE_NOT_FOUND (cross-account without RAM share — see multi-account guide).

Listing associations

import {
  ListServiceNetworkVpcAssociationsCommand,
  ListServiceNetworkServiceAssociationsCommand,
  paginateListServiceNetworkVpcAssociations,
  paginateListServiceNetworkServiceAssociations,
} from "@aws-sdk/client-vpc-lattice";

// List all VPC associations for a service network
for await (const page of paginateListServiceNetworkVpcAssociations(
  { client: lattice },
  { serviceNetworkIdentifier: "sn-0abc123def456789a" }
)) {
  for (const assoc of page.items ?? []) {
    console.log(assoc.vpcId, assoc.status, assoc.createdAt);
  }
}

// List all service associations
for await (const page of paginateListServiceNetworkServiceAssociations(
  { client: lattice },
  { serviceNetworkIdentifier: "sn-0abc123def456789a" }
)) {
  for (const assoc of page.items ?? []) {
    console.log(assoc.name, assoc.status, assoc.dnsEntry?.domainName);
  }
}

Service network auth policies

The service network auth policy acts as an outer gate — evaluated before the service-level auth policy. If the service network policy denies a request, it never reaches the service. Set a permissive network policy that allows all org principals, then use service-level policies for fine-grained restrictions:

import { PutAuthPolicyCommand } from "@aws-sdk/client-vpc-lattice";

// Allow any principal from your AWS organization
await lattice.send(new PutAuthPolicyCommand({
  resourceIdentifier: "sn-0abc123def456789a",   // service network ARN or ID
  policy: JSON.stringify({
    Version: "2012-10-17",
    Statement: [{
      Effect: "Allow",
      Principal: "*",
      Action: "vpc-lattice-svcs:Invoke",
      Resource: "*",
      Condition: {
        StringEquals: {
          "aws:PrincipalOrgID": "o-abc123def456",
        },
      },
    }],
  }),
}));

When authType is AWS_IAM and you have not set a policy, all requests are denied by default. Even if individual services have permissive policies, the service network is the first gate.

Sharing a service network with RAM

To let VPCs in other AWS accounts associate with your service network, share it via Resource Access Manager. The consumer account then calls CreateServiceNetworkVpcAssociationCommand using the shared service network ARN:

import { RAMClient, CreateResourceShareCommand } from "@aws-sdk/client-ram";

const ram = new RAMClient({ region: "us-east-1" });

await ram.send(new CreateResourceShareCommand({
  name: "mcp-platform-service-network-share",
  resourceArns: [
    "arn:aws:vpc-lattice:us-east-1:123456789012:servicenetwork/sn-0abc123def456789a",
  ],
  principals: [
    "arn:aws:organizations::123456789012:ou/o-abc123def/ou-xyz789",  // entire OU
    // or individual account IDs: "234567890123"
  ],
  allowExternalPrincipals: false,  // only within the same AWS organization
  tags: [{ key: "SharedWith", value: "mcp-consumer-accounts" }],
}));

Consumer accounts see the shared service network in their RAM console under "Shared with me." They accept it and then can associate their VPCs using the service network ARN from the sharing account. The consumer account's VPC association security group and routing apply just as in the same-account case.

CloudWatch metrics for service networks

VPC Lattice publishes metrics to CloudWatch under the AWS/VpcLattice namespace. Useful dimensions: ServiceNetworkName, ServiceName, TargetGroupName.

MetricWhat it measures
RequestCountTotal requests routed through the service network
4xxResponseCount4xx errors from services (client errors, auth failures)
5xxResponseCount5xx errors from services (target failures)
TargetResponseTimeEnd-to-end latency from Lattice to target response
HTTPCode_Target_2XX_CountSuccessful responses from targets

Set CloudWatch alarms on 5xxResponseCount at the service level to detect target health degradation early — this fires faster than waiting for AliveMCP's 60-second MCP endpoint ping to detect downstream failures.

Access logs

Enable VPC Lattice access logs to debug connectivity and auth failures. Logs can be sent to CloudWatch Logs, S3, or Kinesis Firehose:

import { CreateAccessLogSubscriptionCommand } from "@aws-sdk/client-vpc-lattice";

// Log all service network traffic to CloudWatch Logs
await lattice.send(new CreateAccessLogSubscriptionCommand({
  resourceIdentifier: "sn-0abc123def456789a",
  destinationArn: "arn:aws:logs:us-east-1:123456789012:log-group:/vpc-lattice/mcp-platform",
  tags: { Environment: "production" },
}));

Log records include: callerPrincipal (the IAM ARN of the caller), requestMethod, requestPath, statusCode, targetGroupArn, targetId, requestToTargetDuration, and the tlsVersion. When IAM auth fails, the log shows statusCode: 403 and callerPrincipal that tells you exactly which identity was denied.