{"record":{"id":"6ea29cdf4b2baf22","repo":"kubernetes/kops","slug":"subnet-id-not-set","errorCode":null,"errorMessage":"Subnet ID not set","messagePattern":"Subnet ID not set","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/elastic_ip.go","lineNumber":258,"sourceCode":"\t\t\treturn fmt.Errorf(\"error creating ElasticIP: %v\", err)\n\t\t}\n\n\t\te.ID = response.AllocationId\n\t\te.PublicIP = response.PublicIp\n\t\tpublicIp = e.PublicIP\n\t\teipId = response.AllocationId\n\t} else {\n\t\tpublicIp = a.PublicIP\n\t\teipId = a.ID\n\t\tif err := t.AddAWSTags(*e.ID, e.Tags); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Tag the associated subnet\n\tif e.TagOnSubnet != nil {\n\t\tif e.TagOnSubnet.ID == nil {\n\t\t\treturn fmt.Errorf(\"Subnet ID not set\")\n\t\t}\n\t\ttags := make(map[string]string)\n\t\ttags[\"AssociatedElasticIp\"] = *publicIp\n\t\ttags[\"AssociatedElasticIpAllocationId\"] = *eipId // Leaving this in for reference, even though we don't use it\n\t\terr := t.AddAWSTags(*e.TagOnSubnet.ID, tags)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Unable to tag subnet %v\", err)\n\t\t}\n\t} else {\n\t\t// TODO: Figure out what we can do.  We're sort of stuck between wanting to have one code-path with\n\t\t// terraform, and having a bigger \"window of loss\" here before we create the NATGateway\n\t\tklog.V(2).Infof(\"ElasticIP %q not tagged on subnet; risk of leaking\", fi.ValueOf(publicIp))\n\t}\n\n\treturn nil\n}\n\ntype terraformElasticIP struct {","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/elastic_ip.go#L240-L276","documentation":"In RenderAWS, when the task specifies TagOnSubnet (deprecated mechanism to tag the associated subnet so the EIP can be rediscovered), kOps requires that subnet's ID to be resolved. If e.TagOnSubnet.ID is still nil at render time it throws 'Subnet ID not set' rather than tagging an undefined resource.","triggerScenarios":"An ElasticIP task defines TagOnSubnet as a Subnet task reference whose ID was never resolved — e.g. the subnet task hasn't been created/looked up yet, or the spec references a subnet by name that doesn't exist in the cluster so no ID was populated during Find.","commonSituations":"Hand-edited cluster specs referencing a nonexistent subnet for TagOnSubnet; NAT gateway EIP definitions where the subnet task failed earlier in the run; legacy cluster configs using the deprecated TagOnSubnet field after subnet IDs changed.","solutions":["Fix the spec so TagOnSubnet references a real subnet of the cluster (verify with `kops get cluster -oyaml` / kops edit cluster)","Remove TagOnSubnet if not needed — modern kOps discovers NAT-gateway EIPs via AssociatedNatGatewayRouteTable instead","Ensure the referenced Subnet task renders successfully (no earlier errors) so its ID is populated before RenderAWS","Migrate to the AssociatedNatGatewayRouteTable pattern for NAT EIP discovery"],"exampleFix":"// before\ntagOnSubnet: legacy-subnet-name // task ID unresolved\n// after: use route-table association or a valid subnet\nassociatedNatGatewayRouteTable: private-us-east-1a","handlingStrategy":"validation","validationCode":"if e.TagOnSubnet != nil && e.TagOnSubnet.ID == nil {\n    return errors.New(\"TagOnSubnet must reference a resolved subnet with an ID\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"Subnet ID not set\") {\n    // fix spec: point TagOnSubnet at a real subnet or drop the field\n}","preventionTips":["Prefer AssociatedNatGatewayRouteTable over deprecated TagOnSubnet","Ensure referenced subnet tasks resolve successfully before EIP rendering","Validate cluster spec subnet references with kops get cluster -oyaml","Never hand-edit subnet names without updating dependent tasks"],"tags":["aws","elastic-ip","validation","subnet"],"backgroundTag":"required-field-not-set","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}