@@ -210,17 +210,19 @@ func (t *TargetGroup) create(rOpts *ReconcileOptions) error {
210
210
return fmt .Errorf ("Failed TargetGroup creation. Unable to register targets: %s." , err .Error ())
211
211
}
212
212
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
+ }
218
219
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
222
225
}
223
- t .attributes .current = t .attributes .desired
224
226
225
227
return nil
226
228
}
0 commit comments