{"record":{"id":"80d69bb79c888b43","repo":"kubernetes/kops","slug":"error-attaching-loadbalancers-v","errorCode":null,"errorMessage":"error attaching LoadBalancers: %v","messagePattern":"error attaching LoadBalancers: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go","lineNumber":682,"sourceCode":"\t\tif deleteTagsRequest != nil && len(deleteTagsRequest.Tags) > 0 {\n\t\t\tif _, err := t.Cloud.Autoscaling().DeleteTags(ctx, deleteTagsRequest); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error deleting old AutoscalingGroup tags: %v\", err)\n\t\t\t}\n\t\t}\n\t\tif updateTagsRequest != nil {\n\t\t\tif _, err := t.Cloud.Autoscaling().CreateOrUpdateTags(ctx, updateTagsRequest); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error updating AutoscalingGroup tags: %v\", err)\n\t\t\t}\n\t\t}\n\n\t\tif detachLBRequest != nil {\n\t\t\tif _, err := t.Cloud.Autoscaling().DetachLoadBalancers(ctx, detachLBRequest); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error detatching LoadBalancers: %v\", err)\n\t\t\t}\n\t\t}\n\t\tif attachLBRequest != nil {\n\t\t\tif _, err := t.Cloud.Autoscaling().AttachLoadBalancers(ctx, attachLBRequest); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error attaching LoadBalancers: %v\", err)\n\t\t\t}\n\t\t}\n\t\tif len(attachTGRequests) > 0 {\n\t\t\tfor _, attachTGRequest := range attachTGRequests {\n\t\t\t\tif _, err := t.Cloud.Autoscaling().AttachLoadBalancerTargetGroups(ctx, attachTGRequest); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to attach target groups: %v\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// UseMixedInstancesPolicy checks if we should add a mixed instances policy to the asg\nfunc (e *AutoscalingGroup) UseMixedInstancesPolicy() bool {\n\tif e.LaunchTemplate == nil {\n\t\treturn false","sourceCodeStart":664,"sourceCodeEnd":700,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go#L664-L700","documentation":"AttachLoadBalancers failed while attaching classic ELBs to the ASG; the ASG was updated but the load balancer attachment is incomplete. The wrapped error is the raw AWS autoscaling API error.","triggerScenarios":"During ASG update, attachLBRequest is built (a classic load balancer added to the ASG spec) and Autoscaling().AttachLoadBalancers fails: ELB not found or in wrong region/VPC, ELB deleted between check and use, throttling, or missing autoscaling:AttachLoadBalancers permission.","commonSituations":"Adding a loadBalancer attachment to an instance group while the ELB name is misspelled; ELB lives in a different VPC than the ASG subnets; cross-account ELB not shared; throttling during big applies.","solutions":["Verify the load balancer name in the instance group spec exists in the same region/VPC as the ASG subnets.","Ensure kops created the ELB first (run full `kops update cluster --yes`, not a partial apply).","Check IAM permissions include autoscaling:AttachLoadBalancers and ELB read access.","Retry after backoff if throttled."],"exampleFix":"// before: wrong region ELB name\nloadBalancer:\n  loadBalancerName: my-elb-eu-west-1\n// after: kops-managed attachment\nloadBalancer:\n  targetGroupArn: <arn-in-same-vpc>","handlingStrategy":"validation","validationCode":"// verify ELB exists in the ASG region/VPC before attach\nout, err := elbSvc.DescribeLoadBalancers(&elb.DescribeLoadBalancersInput{LoadBalancerNames: []string{lbName}})\nif err != nil || len(out.LoadBalancerDescriptions) == 0 {\n  return fmt.Errorf(\"ELB %s missing or wrong region\", lbName)\n}","typeGuard":null,"tryCatchPattern":"if _, err := svc.AttachLoadBalancers(ctx, req); err != nil {\n  var ae smithy.APIError\n  if errors.As(err, &ae) && ae.ErrorCode() == \"ValidationError\" {\n    return fmt.Errorf(\"check ELB name/VPC in instanceGroup spec: %w\", err)\n  }\n  return retry(err)\n}","preventionTips":["Always run the full `kops update cluster --yes` so load balancers are created before attachment.","Match ELB name spelling exactly (case-sensitive).","Ensure ELB and ASG subnets are in the same VPC."],"tags":["aws","autoscaling","load-balancer","cloud-api"],"backgroundTag":"aws-api-call-failed","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"}