Skip to main content
The Vpc component lets you add an Amazon VPC to your app.

Constructor

sst.config.ts
const vpc = new sst.aws.Vpc("MyVpc");

Parameters

nat

nat
string
default:"managed"
Configure the NAT gateway for private subnets.
{
  nat: "ec2"
}
Options: "managed" (AWS NAT Gateway), "ec2" (EC2-based NAT), or "none".

Properties

id

publicSubnets

privateSubnets

securityGroups

nodes

Examples

Connect a function to a VPC

sst.config.ts
const vpc = new sst.aws.Vpc("MyVpc");

new sst.aws.Function("MyFunction", {
  handler: "src/lambda.handler",
  vpc
});

Reference an existing VPC

sst.config.ts
const vpc = sst.aws.Vpc.get("MyVpc", "vpc-12345678901234567");

Build docs developers (and LLMs) love