{"record":{"id":"2e1f2c8f198c9085","repo":"kubernetes/kops","slug":"error-modifying-target-group-attributes-for-nlb","errorCode":null,"errorMessage":"error modifying target group attributes for NLB : %v","messagePattern":"error modifying target group attributes for NLB : (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/targetgroup.go","lineNumber":433,"sourceCode":"\t\t}\n\t}\n\treturn nil\n}\n\nfunc ModifyTargetGroupAttributes(ctx context.Context, cloud awsup.AWSCloud, arn *string, attributes map[string]string) error {\n\tklog.V(2).Infof(\"Modifying Target Group attributes for NLB\")\n\tattrReq := &elbv2.ModifyTargetGroupAttributesInput{\n\t\tAttributes:     []elbv2types.TargetGroupAttribute{},\n\t\tTargetGroupArn: arn,\n\t}\n\tfor k, v := range attributes {\n\t\tattrReq.Attributes = append(attrReq.Attributes, elbv2types.TargetGroupAttribute{\n\t\t\tKey:   new(k),\n\t\t\tValue: new(v),\n\t\t})\n\t}\n\tif _, err := cloud.ELBV2().ModifyTargetGroupAttributes(ctx, attrReq); err != nil {\n\t\treturn fmt.Errorf(\"error modifying target group attributes for NLB : %v\", err)\n\t}\n\treturn nil\n}\n\n// OrderTargetGroupsByName implements sort.Interface for []OrderTargetGroupsByName, based on port number\ntype OrderTargetGroupsByName []*TargetGroup\n\nfunc (a OrderTargetGroupsByName) Len() int      { return len(a) }\nfunc (a OrderTargetGroupsByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a OrderTargetGroupsByName) Less(i, j int) bool {\n\treturn fi.ValueOf(a[i].Name) < fi.ValueOf(a[j].Name)\n}\n\ntype terraformTargetGroup struct {\n\tName                  string                          `cty:\"name\"`\n\tPort                  int32                           `cty:\"port\"`\n\tProtocol              elbv2types.ProtocolEnum         `cty:\"protocol\"`\n\tVPCID                 *terraformWriter.Literal        `cty:\"vpc_id\"`","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/targetgroup.go#L415-L451","documentation":"ModifyTargetGroupAttributes applies key/value attributes (e.g. deregistration_delay, stickiness) to an NLB target group via ModifyTargetGroupAttributes and wraps any API error with %v. The target group exists but its attributes could not be set.","triggerScenarios":"Called from RenderAWS right after CreateTargetGroup; fails when an attribute key/value is invalid for the target group type (e.g. stickiness on unsupported protocol), IAM lacks elasticloadbalancing:ModifyTargetGroupAttributes, or AWS throttles/rejects the call.","commonSituations":"Attributes map in the TargetGroup spec contains keys invalid for the group's protocol/type; permission gaps in the kops IAM policy; transient AWS API failures during apply.","solutions":["Check the wrapped AWS error; correct invalid attribute keys/values in the target group Attributes spec","Verify IAM includes elasticloadbalancing:ModifyTargetGroupAttributes","Re-run `kops update cluster` after transient API errors"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// check attribute keys against AWS docs for the group's protocol/type before apply\nvalid := map[string]bool{\"deregistration_delay.connection_termination.enabled\":true, \"proxy_protocol_v2.enabled\":true, \"stickiness.enabled\":true, ...}\nfor k := range attrs { if !valid[k] { return fmt.Errorf(\"invalid target group attribute %q\", k) } }","typeGuard":null,"tryCatchPattern":"if err := applyCluster(); err != nil && strings.Contains(err.Error(), \"error modifying target group attributes\") {\n  return fmt.Errorf(\"invalid Attributes key/value for this target group type: %w\", err)\n}","preventionTips":["Only set attributes valid for the group's protocol (e.g. stickiness requires certain protocols)","Grant elasticloadbalancing:ModifyTargetGroupAttributes","Retry transient AWS errors","Match attribute keys exactly against the ELBV2 API reference"],"tags":["aws","elbv2","target-group-attributes"],"backgroundTag":"aws-api-modify-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"}