Skip to content

Commit b1de5bc

Browse files
committed
Prevent setting an empty TG attributes list
1 parent bd28aa9 commit b1de5bc

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

pkg/alb/tg/targetgroup.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,19 @@ func (t *TargetGroup) create(rOpts *ReconcileOptions) error {
210210
return fmt.Errorf("Failed TargetGroup creation. Unable to register targets: %s.", err.Error())
211211
}
212212

213-
// Add TargetGroup attributes
214-
attributes := &elbv2.ModifyTargetGroupAttributesInput{
215-
Attributes: t.attributes.desired,
216-
TargetGroupArn: t.CurrentARN(),
217-
}
213+
if len(t.attributes.desired) > 0 {
214+
// Add TargetGroup attributes
215+
attributes := &elbv2.ModifyTargetGroupAttributesInput{
216+
Attributes: t.attributes.desired,
217+
TargetGroupArn: t.CurrentARN(),
218+
}
218219

219-
if _, err := albelbv2.ELBV2svc.ModifyTargetGroupAttributes(attributes); err != nil {
220-
rOpts.Eventf(api.EventTypeWarning, "ERROR", "Error adding attributes to target group %s: %s", t.ID, err.Error())
221-
return fmt.Errorf("Failed TargetGroup creation. Unable to add target group attributes: %s.", err.Error())
220+
if _, err := albelbv2.ELBV2svc.ModifyTargetGroupAttributes(attributes); err != nil {
221+
rOpts.Eventf(api.EventTypeWarning, "ERROR", "Error adding attributes to target group %s: %s", t.ID, err.Error())
222+
return fmt.Errorf("Failed TargetGroup creation. Unable to add target group attributes: %s.", err.Error())
223+
}
224+
t.attributes.current = t.attributes.desired
222225
}
223-
t.attributes.current = t.attributes.desired
224226

225227
return nil
226228
}

0 commit comments

Comments
 (0)