{"record":{"id":"763115ab9c44cdc3","repo":"kubernetes/kops","slug":"id-must-be-set-if-natgateway-is-shared-s","errorCode":null,"errorMessage":"ID must be set, if NatGateway is shared: %s","messagePattern":"ID must be set, if NatGateway is shared: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/natgateway.go","lineNumber":377,"sourceCode":"\t\terr = t.AddAWSTags(fi.ValueOf(e.AssociatedRouteTable.ID), tags)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to tag route table %v\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\ntype terraformNATGateway struct {\n\tAllocationID *terraformWriter.Literal `cty:\"allocation_id\"`\n\tSubnetID     *terraformWriter.Literal `cty:\"subnet_id\"`\n\tTag          map[string]string        `cty:\"tags\"`\n}\n\nfunc (_ *NatGateway) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *NatGateway) error {\n\tif fi.ValueOf(e.Shared) {\n\t\tif e.ID == nil {\n\t\t\treturn fmt.Errorf(\"ID must be set, if NatGateway is shared: %s\", e)\n\t\t}\n\n\t\tklog.V(4).Infof(\"reusing existing NatGateway with id %q\", *e.ID)\n\t\treturn nil\n\t}\n\n\ttf := &terraformNATGateway{\n\t\tAllocationID: e.ElasticIP.TerraformLink(),\n\t\tSubnetID:     e.Subnet.TerraformLink(),\n\t\tTag:          e.Tags,\n\t}\n\n\treturn t.RenderResource(\"aws_nat_gateway\", *e.Name, tf)\n}\n\nfunc (e *NatGateway) TerraformLink() *terraformWriter.Literal {\n\tif fi.ValueOf(e.Shared) {\n\t\tif e.ID == nil {","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/natgateway.go#L359-L395","documentation":"In RenderTerraform for NatGateway, if the gateway is marked Shared the terraform target cannot create a new one; it requires the existing gateway's ID. When e.Shared is true and e.ID is nil, it errors \"ID must be set, if NatGateway is shared: %s\".","triggerScenarios":"Terraform output target renders a NatGateway task with fi.ValueOf(e.Shared)==true and e.ID==nil — a spec marked shared without supplying the existing NGW's ID (nat-...).","commonSituations":"Switching a cluster to a pre-existing NAT gateway when using kops update --target=terraform; cluster spec copied from a non-shared setup; ID omitted from the shared config.","solutions":["Set the ID field of the shared NatGateway task to the existing nat-gateway ID (nat-xxxxxxxx)","Confirm with aws ec2 describe-nat-gateways that the ID exists and is available","Re-run kops update --target=terraform"],"exampleFix":"// before\nshared: true\n// after\nshared: true\nid: nat-0abc1234def567890","handlingStrategy":"validation","validationCode":"if fi.ValueOf(nat.Shared) && nat.ID == nil {\n    return fmt.Errorf(\"shared nat gateway must set ID (nat-...)\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair shared: true with the existing NGW ID","Verify the nat- ID with aws ec2 describe-nat-gateways","Run terraform target with --dry-run first"],"tags":["aws","nat-gateway","terraform","shared"],"backgroundTag":"missing-required-argument","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}