{"record":{"id":"f62614d84e988078","repo":"anomalyco/sst","slug":"cloud-map-namespace-not-found-for-vpc-vpcid","errorCode":null,"errorMessage":"Cloud Map namespace not found for VPC ${vpcId}","messagePattern":"Cloud Map namespace not found for VPC (.+?)","errorType":"validation","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/vpc.ts","lineNumber":742,"sourceCode":"      // }).id;\n      // ```\n      // but if user deployed multiple VPCs into the same account. This will error because\n      // there are multiple results. Even though `getDnsNamespaceOutput()` takes tags in args,\n      // the tags are not used for lookup.\n      const zone = output(vpcId).apply((vpcId) =>\n        route53.getZone(\n          {\n            name: \"sst\",\n            privateZone: true,\n            vpcId,\n          },\n          { parent: self },\n        ),\n      );\n      const namespaceId = zone.linkedServiceDescription.apply((description) => {\n        const match = description.match(/:namespace\\/(ns-[a-z1-9]*)/)?.[1];\n        if (!match) {\n          throw new VisibleError(\n            `Cloud Map namespace not found for VPC ${vpcId}`,\n          );\n        }\n        return match;\n      });\n      const cloudmapNamespace = servicediscovery.PrivateDnsNamespace.get(\n        `${name}CloudmapNamespace`,\n        namespaceId,\n        { vpc: vpcId },\n        { parent: self },\n      );\n\n      const privateKeyValue = bastionInstance.apply((v) => {\n        if (!v) return;\n        const param = ssm.Parameter.get(\n          `${name}PrivateKeyValue`,\n          interpolate`/sst/vpc/${vpcId}/private-key-value`,\n          undefined,","sourceCodeStart":724,"sourceCodeEnd":760,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/vpc.ts#L724-L760","documentation":"This SST VPC component error is thrown when SST tries to look up the Cloud Map (servicediscovery) PrivateDnsNamespace associated with the VPC but cannot find its ID by parsing the linked service discovery description. It means the VPC's Cloud Map namespace resource is missing, was created outside SST, or the expected namespace link description does not contain a namespace ID of the form ns-*.","triggerScenarios":"Referencing a VPC component (via `ref`) whose linkedServiceDescription does not match the regex /:namespace\\/(ns-[a-z1-9]*)/, e.g. the PrivateDnsNamespace was deleted out-of-band, was imported manually, or the VPC was created without a Cloud Map namespace.","commonSituations":"Manual deletion or recreation of the Cloud Map namespace in the AWS console while the Pulumi state still references it; importing an existing VPC that has no private DNS namespace; drift between SST state and actual AWS resources.","solutions":["Verify the Cloud Map Private DNS namespace still exists in the AWS console for this VPC and starts with 'ns-'.","If it was deleted out-of-band, remove and redeploy the VPC component so SST recreates the namespace.","If importing an existing VPC, create/import a servicediscovery.PrivateDnsNamespace and link it so the description matches ':namespace/ns-...'.","Refresh state (sst refresh / pulumi refresh) to reconcile drift, then redeploy."],"exampleFix":"// before: namespace deleted manually, SST can't find it\nconst vpc = new sst.aws.Vpc(\"MyVPC\");\n// after: remove from state and redeploy so the namespace is recreated\n// sst remove MyVPC && sst deploy  (or refresh state first)","handlingStrategy":"validation","validationCode":"// before deploying, verify the namespace exists in the target VPC\nimport { ServiceDiscoveryClient, ListNamespacesCommand } from \"@aws-sdk/client-servicediscovery\";\nconst ns = await sd.send(new ListNamespacesCommand({})).then(r =>\n  r.Namespaces?.find(n => n.Properties?.Vpc === vpcId));\nif (!ns) throw new Error(`No Cloud Map namespace found for VPC ${vpcId}; recreate the VPC via SST first.`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Don't delete the PrivateDnsNamespace from the AWS console for SST-managed VPCs","Run state refresh after any manual out-of-band AWS changes","When importing existing VPCs, ensure a private DNS namespace exists and is linked"],"tags":["aws","cloudmap","vpc","servicediscovery"],"backgroundTag":"cloud-map-namespace-not-found","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}