Skip to content

NextjsSite cdk.server.vpc ignored in SST v2.47.1 (no VPC attached despite docs support) #115

@perperj-super

Description

@perperj-super

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions