{"record":{"id":"6ac70b143b04ad5c","repo":"anomalyco/sst","slug":"missing-nat-type-for-the-name-vpc-it-is-re","errorCode":null,"errorMessage":"Missing \"nat.type\" for the \"${name}\" VPC. It is required when \"nat.ec2\" is not specified.","messagePattern":"Missing \"nat\\.type\" for the \"(.+?)\" VPC\\. It is required when \"nat\\.ec2\" is not specified\\.","errorType":"validation","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/vpc.ts","lineNumber":868,"sourceCode":"    function normalizeNat() {\n      return all([args.nat, zones]).apply(([nat, zones]) => {\n        if (nat === \"managed\") {\n          return { type: \"managed\" as const };\n        }\n        if (nat === \"ec2\") {\n          return {\n            type: \"ec2\" as const,\n            ec2: { instance: \"t4g.nano\", ami: undefined, role: undefined },\n          };\n        }\n        if (nat) {\n          if (nat.ec2 && nat.type === \"managed\")\n            throw new VisibleError(\n              `The \"nat.type\" cannot be \"managed\" when \"nat.ec2\" is specified.`,\n            );\n\n          if (!nat.type && !nat.ec2)\n            throw new VisibleError(\n              `Missing \"nat.type\" for the \"${name}\" VPC. It is required when \"nat.ec2\" is not specified.`,\n            );\n\n          if (nat.ip && nat.ip.length !== zones.length)\n            throw new VisibleError(\n              `The number of Elastic IP allocation IDs must match the number of AZs.`,\n            );\n\n          return nat.ec2 || nat.type === \"ec2\"\n            ? {\n                type: \"ec2\" as const,\n                ip: nat.ip,\n                ec2: {\n                  instance: nat.ec2?.instance ?? \"t4g.nano\",\n                  ami: nat.ec2?.ami,\n                  role: nat.ec2?.role,\n                },\n              }","sourceCodeStart":850,"sourceCodeEnd":886,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/vpc.ts#L850-L886","documentation":"Thrown by normalizeNat when neither `nat.type` nor `nat.ec2` is provided. When any NAT configuration object is present, SST requires you to say whether you want a managed NAT gateway (type: \"managed\") or an EC2-based NAT instance (type: \"ec2\" or an ec2 block), because it cannot infer the mode.","triggerScenarios":"Passing `{ nat: { ip: [...] } }` or `{ nat: {} }` (any nat object without type or ec2) to `new sst.aws.Vpc()` for VPC \"${name}\".","commonSituations":"Setting only elastic IP allocation IDs (nat.ip) while forgetting nat.type; trimming a config example and accidentally removing the type field; upgrading SST where nat config became stricter.","solutions":["Add `nat.type: \"managed\"` for managed NAT gateways.","Or add `nat.type: \"ec2\"` (or an `nat.ec2` block with instance/ami/role) for a NAT instance.","Check the SST VPC docs for the current nat schema."],"exampleFix":"// before\nnew sst.aws.Vpc(\"MyVPC\", { nat: { ip: [\"eipalloc-123\", \"eipalloc-456\"] } });\n// after\nnew sst.aws.Vpc(\"MyVPC\", { nat: { type: \"managed\", ip: [\"eipalloc-123\", \"eipalloc-456\"] } });","handlingStrategy":"validation","validationCode":"function validateNat(nat, name) {\n  if (nat && !nat.type && !nat.ec2)\n    throw new Error(`Set nat.type (\"managed\" or \"ec2\") for the \"${name}\" VPC.`);\n}\nvalidateNat(args.nat, \"MyVPC\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair nat.ip with an explicit nat.type","Use TypeScript types from sst (sst.aws.VpcArgs) to catch missing required fields at compile time","Refer to the SST VPC docs when enabling NAT"],"tags":["vpc","nat","config-validation","aws"],"backgroundTag":"missing-required-vpc-nat-type","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}