Guide · AWS VPC Lattice · Auth Policies
VPC Lattice Auth Policies and IAM SigV4 Signing for MCP Servers
AWS VPC Lattice authentication gives MCP servers a zero-trust access layer without an API Gateway or Cognito authorizer. When you set authType: "AWS_IAM" on a service (or service network), every incoming request must carry a valid SigV4 signature, and the service's auth policy is evaluated just like an IAM resource policy. This guide covers how auth policies are structured, the IAM condition keys unique to VPC Lattice, writing Node.js request-signing code, and the two-sided IAM model (resource policy on the service + identity policy on the caller).
TL;DR
VPC Lattice auth uses two layers: a resource-based policy attached to the service (and optionally the service network) evaluated by Lattice, and an identity-based policy attached to the caller's IAM role granting vpc-lattice-svcs:Invoke. Both must allow the request — a 403 means one is missing. Sign requests with SigV4 using service name vpc-lattice-svcs. Unique condition keys include vpc-lattice:SourceVpc, vpc-lattice:RequestMethod, and vpc-lattice:RequestHeader/{key}.
How VPC Lattice auth evaluation works
When a request arrives at a VPC Lattice service with authType: "AWS_IAM", Lattice performs evaluation in this order:
- Verify the SigV4 signature. Invalid or missing signature → 403 immediately, no policy evaluation.
- Evaluate the service network auth policy (if one exists and the service network is
AWS_IAM). An explicit Deny here stops the request. - Evaluate the service auth policy. Must have an explicit Allow for the principal+action combination.
- VPC Lattice does not check the caller's identity-based IAM policy — but the caller still needs
vpc-lattice-svcs:Invokein their identity policy to sign the request (the IAM service validates this separately for the credentials used to sign).
The practical implication: a service with authType: "AWS_IAM" and no auth policy set is an implicit deny — no caller can reach it. You must explicitly allow principals.
Service auth policy structure
The auth policy syntax is identical to IAM resource policies. The service resource is implicitly the target, so Resource: "*" is always used in auth policies (you cannot scope to a sub-resource of the service).
import { VpcLatticeClient, PutAuthPolicyCommand } from "@aws-sdk/client-vpc-lattice";
const lattice = new VpcLatticeClient({ region: "us-east-1" });
// Allow a specific IAM role from account 123456789012
await lattice.send(new PutAuthPolicyCommand({
resourceIdentifier: "svc-0xyz789ghi012345b",
policy: JSON.stringify({
Version: "2012-10-17",
Statement: [
{
Sid: "AllowMcpServerRole",
Effect: "Allow",
Principal: {
AWS: "arn:aws:iam::123456789012:role/mcp-server-task-role",
},
Action: "vpc-lattice-svcs:Invoke",
Resource: "*",
},
],
}),
}));
Allow multiple principals with conditions
// Allow any role in accounts within the same AWS organization,
// but only from specific VPCs and only for GET/POST requests
await lattice.send(new PutAuthPolicyCommand({
resourceIdentifier: "svc-0xyz789ghi012345b",
policy: JSON.stringify({
Version: "2012-10-17",
Statement: [
{
Sid: "AllowOrgMembersFromApprovedVpcs",
Effect: "Allow",
Principal: "*",
Action: "vpc-lattice-svcs:Invoke",
Resource: "*",
Condition: {
StringEquals: {
"aws:PrincipalOrgID": "o-abc123def456",
"vpc-lattice:SourceVpc": [
"vpc-0mcp1server2vpc34",
"vpc-0staging2server3abc",
],
},
StringEqualsIgnoreCase: {
"vpc-lattice:RequestMethod": ["GET", "POST"],
},
},
},
],
}),
}));
VPC Lattice condition keys
VPC Lattice exposes condition keys that standard IAM resource policies cannot use — they carry request-time metadata injected by the Lattice data plane:
| Condition key | Type | Description |
|---|---|---|
vpc-lattice:SourceVpc |
String | VPC ID of the caller (the VPC associated with the service network) |
vpc-lattice:SourceVpcOwnerAccount |
String | AWS account ID that owns the caller's VPC |
vpc-lattice:RequestMethod |
String | HTTP method: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS |
vpc-lattice:RequestHeader/{key} |
String | Value of a specific request header; e.g. vpc-lattice:RequestHeader/x-mcp-tenant |
aws:PrincipalOrgID |
String | AWS Organizations ID — allows all principals in the org |
aws:PrincipalAccount |
String | AWS account ID of the caller's IAM principal |
aws:PrincipalArn |
String | Full IAM ARN of the caller's role or user |
aws:PrincipalTag/{key} |
String | Tag on the caller's IAM principal — useful for ABAC |
Note: aws:SourceVpc (the classic condition key for VPC endpoint policies) does not work in VPC Lattice auth policies. Use vpc-lattice:SourceVpc instead.
Caller identity-based policy
The IAM role or user that signs the request needs an identity-based policy granting vpc-lattice-svcs:Invoke. Without this, the credentials are valid but the IAM service will deny signing or the request will arrive unsigned:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowVpcLatticeInvoke",
"Effect": "Allow",
"Action": "vpc-lattice-svcs:Invoke",
"Resource": "*"
}
]
}
To scope to a specific service, use the service ARN:
{
"Statement": [
{
"Effect": "Allow",
"Action": "vpc-lattice-svcs:Invoke",
"Resource": "arn:aws:vpc-lattice:us-east-1:123456789012:service/svc-0xyz789ghi012345b"
}
]
}
SigV4 signing in Node.js with @aws-sdk/signature-v4
VPC Lattice uses standard AWS SigV4 with the service name vpc-lattice-svcs. The @aws-sdk/signature-v4 package (included with the AWS SDK) handles the signing mechanics:
import { SignatureV4 } from "@aws-sdk/signature-v4";
import { Sha256 } from "@aws-crypto/sha256-js";
import { defaultProvider } from "@aws-sdk/credential-provider-node";
// Create a signer once at module level (credentials refresh automatically)
const signer = new SignatureV4({
credentials: defaultProvider(),
region: "us-east-1",
service: "vpc-lattice-svcs", // critical: not "execute-api" or "vpc-lattice"
sha256: Sha256,
});
async function callLatticeService(
domainName: string,
path: string,
method: string = "GET",
body?: string
): Promise<Response> {
const url = new URL(`https://${domainName}${path}`);
const request = {
method,
hostname: url.hostname,
path: url.pathname + url.search,
headers: {
host: url.hostname,
"content-type": "application/json",
...(body ? { "content-length": String(Buffer.byteLength(body)) } : {}),
},
body: body ?? undefined,
protocol: "https:" as const,
};
const signed = await signer.sign(request);
return fetch(`https://${url.hostname}${url.pathname}${url.search}`, {
method: signed.method,
headers: signed.headers,
body,
});
}
Usage from an MCP server tool handler:
const LATTICE_HOST = "mcp-data-service-0a1b2c.mcp-platform-3d4e5f.vpc-lattice-svcs.us-east-1.on.aws";
// In your MCP tool handler:
server.tool("get-items", { query: z.string() }, async ({ query }) => {
const response = await callLatticeService(
LATTICE_HOST,
`/api/items?q=${encodeURIComponent(query)}`
);
if (!response.ok) {
throw new Error(`Lattice service returned ${response.status}`);
}
const data = await response.json();
return { content: [{ type: "text", text: JSON.stringify(data) }] };
});
Lightweight alternative: the aws4 package
If you prefer a smaller dependency, the aws4 npm package also signs VPC Lattice requests correctly. Specify service: "vpc-lattice-svcs":
import aws4 from "aws4";
import https from "https";
// aws4 reads AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN from env
const opts = aws4.sign({
host: "mcp-data-service-0a1b2c.mcp-platform-3d4e5f.vpc-lattice-svcs.us-east-1.on.aws",
path: "/api/items",
service: "vpc-lattice-svcs",
region: "us-east-1",
method: "GET",
});
const req = https.request(opts, (res) => {
let body = "";
res.on("data", (chunk) => (body += chunk));
res.on("end", () => console.log(JSON.parse(body)));
});
req.end();
The aws4 package does not automatically refresh temporary credentials from IMDS or ECS task metadata — if your MCP server runs on EC2 or Fargate, prefer @aws-sdk/credential-provider-node for automatic credential rotation.
Reading and deleting auth policies
import {
GetAuthPolicyCommand,
DeleteAuthPolicyCommand,
} from "@aws-sdk/client-vpc-lattice";
// Get the current policy
const { policy, state } = await lattice.send(new GetAuthPolicyCommand({
resourceIdentifier: "svc-0xyz789ghi012345b",
}));
console.log("Auth policy state:", state); // "Active" | "Inactive"
console.log("Policy:", JSON.parse(policy ?? "{}"));
// Delete the policy (returns service to implicit deny when authType is AWS_IAM)
await lattice.send(new DeleteAuthPolicyCommand({
resourceIdentifier: "svc-0xyz789ghi012345b",
}));
// After deletion: all requests return 403 until a new policy is set
Policy state Inactive means the policy was set but Lattice is not enforcing it yet — this is a brief propagation window, usually seconds. If you see Inactive during a deployment, retry after a few seconds before concluding the policy is wrong.
ABAC with principal tags
When multiple teams run MCP servers and you want to scope what each team can call without maintaining a list of role ARNs, use Attribute-Based Access Control via aws:PrincipalTag. Tag each team's IAM role with Team=data-platform or Team=search-service, then use that in the auth policy:
// IAM role tag: Team=data-platform (set on the role, not the session)
// The session tag propagates if set via AssumeRole with SessionTags
await lattice.send(new PutAuthPolicyCommand({
resourceIdentifier: "svc-0xyz789ghi012345b",
policy: JSON.stringify({
Version: "2012-10-17",
Statement: [
{
Sid: "AllowDataPlatformTeam",
Effect: "Allow",
Principal: "*",
Action: "vpc-lattice-svcs:Invoke",
Resource: "*",
Condition: {
StringEquals: {
"aws:PrincipalOrgID": "o-abc123def456",
"aws:PrincipalTag/Team": "data-platform",
},
},
},
],
}),
}));
This avoids updating auth policies when teams add new IAM roles — only the tag value needs to match.
Header-based routing with auth
VPC Lattice can require a specific header value as an additional auth condition. This is useful for multi-tenant MCP servers where each tenant gets a different JWT or API version header:
// Allow calls that include the correct internal API version header
await lattice.send(new PutAuthPolicyCommand({
resourceIdentifier: "svc-0xyz789ghi012345b",
policy: JSON.stringify({
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Principal: { AWS: "arn:aws:iam::123456789012:role/mcp-server-task-role" },
Action: "vpc-lattice-svcs:Invoke",
Resource: "*",
Condition: {
StringEquals: {
"vpc-lattice:RequestHeader/x-api-version": "v2",
},
},
},
],
}),
}));
Header condition keys are case-insensitive on the key name but case-sensitive on the value. Use StringEqualsIgnoreCase if you need case-insensitive value matching.
Debugging auth failures
When a request returns 403, the VPC Lattice access logs (enabled via CreateAccessLogSubscriptionCommand) provide the essential fields:
callerPrincipal— which IAM ARN signed the request; confirms if the credential chain is picking up the right rolestatusCode— 403 means auth policy denied; 401 means signature was missing or invalidauthDeniedReason—Organization(OrgID condition failed),Principal(principal not allowed),Method(method condition failed),None(no policy matched)
A 403 with authDeniedReason: None usually means the auth policy has no matching Allow statement — either the principal ARN does not match, the OrgID condition is wrong, or the action string is misspelled.