kubernetes/kops · error

error modifying target group attributes for NLB : %v

Error message

error modifying target group attributes for NLB : %v

What it means

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.

Source

Thrown at upup/pkg/fi/cloudup/awstasks/targetgroup.go:433

		}
	}
	return nil
}

func ModifyTargetGroupAttributes(ctx context.Context, cloud awsup.AWSCloud, arn *string, attributes map[string]string) error {
	klog.V(2).Infof("Modifying Target Group attributes for NLB")
	attrReq := &elbv2.ModifyTargetGroupAttributesInput{
		Attributes:     []elbv2types.TargetGroupAttribute{},
		TargetGroupArn: arn,
	}
	for k, v := range attributes {
		attrReq.Attributes = append(attrReq.Attributes, elbv2types.TargetGroupAttribute{
			Key:   new(k),
			Value: new(v),
		})
	}
	if _, err := cloud.ELBV2().ModifyTargetGroupAttributes(ctx, attrReq); err != nil {
		return fmt.Errorf("error modifying target group attributes for NLB : %v", err)
	}
	return nil
}

// OrderTargetGroupsByName implements sort.Interface for []OrderTargetGroupsByName, based on port number
type OrderTargetGroupsByName []*TargetGroup

func (a OrderTargetGroupsByName) Len() int      { return len(a) }
func (a OrderTargetGroupsByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a OrderTargetGroupsByName) Less(i, j int) bool {
	return fi.ValueOf(a[i].Name) < fi.ValueOf(a[j].Name)
}

type terraformTargetGroup struct {
	Name                  string                          `cty:"name"`
	Port                  int32                           `cty:"port"`
	Protocol              elbv2types.ProtocolEnum         `cty:"protocol"`
	VPCID                 *terraformWriter.Literal        `cty:"vpc_id"`

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check the wrapped AWS error; correct invalid attribute keys/values in the target group Attributes spec
  2. Verify IAM includes elasticloadbalancing:ModifyTargetGroupAttributes
  3. Re-run `kops update cluster` after transient API errors
Defensive patterns

Strategy: validation

Validate before calling

// check attribute keys against AWS docs for the group's protocol/type before apply
valid := map[string]bool{"deregistration_delay.connection_termination.enabled":true, "proxy_protocol_v2.enabled":true, "stickiness.enabled":true, ...}
for k := range attrs { if !valid[k] { return fmt.Errorf("invalid target group attribute %q", k) } }

Try / catch

if err := applyCluster(); err != nil && strings.Contains(err.Error(), "error modifying target group attributes") {
  return fmt.Errorf("invalid Attributes key/value for this target group type: %w", err)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/2e1f2c8f198c9085. Report an issue: GitHub.