-
Notifications
You must be signed in to change notification settings - Fork 53
Closed as duplicate
Closed as duplicate
Copy link
Description
Environment
- SST version:
2.47.1 - AWS CDK version:
2.171.1 - Node.js version:
20.x - Region:
us-east-1 - Deployment type:
NextjsSite (edge: false)
Expected behavior
According to the official SST v2 documentation,
the cdk.server.vpc and cdk.server.vpcSubnets properties should attach all Next.js Lambda functions
(SSR, API, revalidation, image optimization) to the specified VPC when deploying in single-region mode (edge: false).
Actual behavior
The Lambda functions are not placed in the specified VPC.
When checked with the AWS CLI, VpcConfig returns null.
No error or warning is thrown — the configuration is silently ignored.
Current code
import { NextjsSite, StackContext } from "sst/constructs";
import * as ec2 from "aws-cdk-lib/aws-ec2";
export function NextJSStack({ stack }: StackContext) {
const vpc = ec2.Vpc.fromLookup(stack, "SharedVpc", {
vpcId: process.env.SHARED_VPC_ID!,
});
const privateSubnets = process.env.PRIVATE_SUBNET_IDS!
.split(",")
.map((id, i) => ec2.Subnet.fromSubnetId(stack, `PrivateSubnet${i}`, id));
new NextjsSite(stack, "Site", {
...,
edge: false,
...,
cdk: {
server: { vpc, vpcSubnets: { subnets: privateSubnets } },
revalidation: { vpc, vpcSubnets: { subnets: privateSubnets } },
imageOptimization: { vpc, vpcSubnets: { subnets: privateSubnets } },
},
});
}Result
aws lambda get-function-configuration \
--function-name MyApp-SiteServerFunctionXXXX \
--region us-east-1 \
--query "VpcConfig"
=> null
Metadata
Metadata
Assignees
Labels
No labels