{"record":{"id":"0f83ce2255e56557","repo":"kubernetes/kops","slug":"found-multiple-elbs-with-name-q","errorCode":null,"errorMessage":"Found multiple ELBs with name %q","messagePattern":"Found multiple ELBs with name %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/classic_load_balancer.go","lineNumber":83,"sourceCode":"\t\t}\n\n\t\tklog.Warningf(\"Got ELB with unexpected name: %q\", aws.ToString(lb.LoadBalancerName))\n\t\treturn false\n\t})\n\tif err != nil {\n\t\tif awsup.AWSErrorCode(err) == \"LoadBalancerNotFound\" {\n\t\t\treturn nil, nil\n\t\t}\n\n\t\treturn nil, fmt.Errorf(\"error listing ELBs: %v\", err)\n\t}\n\n\tif len(found) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tif len(found) != 1 {\n\t\treturn nil, fmt.Errorf(\"Found multiple ELBs with name %q\", loadBalancerName)\n\t}\n\n\treturn &found[0], nil\n}\n\nfunc describeLoadBalancers(ctx context.Context, cloud awsup.AWSCloud, request *elb.DescribeLoadBalancersInput, filter func(elbtypes.LoadBalancerDescription) bool) ([]elbtypes.LoadBalancerDescription, error) {\n\tvar found []elbtypes.LoadBalancerDescription\n\tpaginator := elb.NewDescribeLoadBalancersPaginator(cloud.ELB(), request)\n\tfor paginator.HasMorePages() {\n\t\toutput, err := paginator.NextPage(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error listing ELBs: %w\", err)\n\t\t}\n\n\t\tfor _, lb := range output.LoadBalancerDescriptions {\n\t\t\tif filter(lb) {\n\t\t\t\tfound = append(found, lb)\n\t\t\t}","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/classic_load_balancer.go#L65-L101","documentation":"Thrown when the name-based ELB search returns more than one match: two or more classic load balancers in the region match the filter for the given load balancer name. Find requires a unique ELB and refuses to pick one arbitrarily.","triggerScenarios":"Multiple classic ELBs share the same LoadBalancerName pattern being filtered (note ELB names are region-unique, so this usually means the filter matches tagged/name-prefixed duplicates) or stale/duplicate ELBs left from previous applies.","commonSituations":"Leftover ELBs from deleted clusters with the same cluster name; running two clusters with the same name in one region; manual duplicate creation.","solutions":["Run aws elb describe-load-balancers and identify the duplicates","Delete the stale/unused ELB (aws elb delete-load-balancer)","Ensure cluster names are unique per region to avoid name collisions","Clean up orphaned ELBs before re-running kops apply"],"exampleFix":"// before: two ELBs with same name pattern\naws elb delete-load-balancer --load-balancer-name mycluster-api  # stale one\n// after: only the correct ELB remains\naws elb describe-load-balancers --query 'LoadBalancerDescriptions[].LoadBalancerName'","handlingStrategy":"validation","validationCode":"aws elb describe-load-balancers --query \"LoadBalancerDescriptions[?LoadBalancerName=='$LB_NAME'] | length(@)\"\n# expect 1 before running kops apply","typeGuard":null,"tryCatchPattern":"catch (err) {\n  if (String(err).startsWith('Found multiple ELBs with name')) {\n    // list and delete stale duplicates, then retry\n  }\n  throw err;\n}","preventionTips":["Use unique cluster names per region","Clean up orphaned ELBs from deleted clusters","Keep one IaC tool as the ELB source of truth"],"tags":["aws","elb","classic-load-balancer","duplicate-resource"],"backgroundTag":"duplicate-resource-found","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"}