diff --git a/cmd/service_destroy.go b/cmd/service_destroy.go index 7b191ac..6aa7d44 100644 --- a/cmd/service_destroy.go +++ b/cmd/service_destroy.go @@ -61,7 +61,7 @@ func destroyService(operation *ServiceDestroyOperation) { ) } - elbv2.ModifyLoadBalancerDefaultAction(loadBalancer.Arn, defaultTargetGroupArn) + elbv2.ModifyListenerDefaultAction(listener.Arn, defaultTargetGroupArn) } else { elbv2.DeleteRule(rule.Arn) } diff --git a/elbv2/listener.go b/elbv2/listener.go index 9db6239..f7eabb5 100644 --- a/elbv2/listener.go +++ b/elbv2/listener.go @@ -90,21 +90,23 @@ func (elbv2 *ELBV2) CreateListener(i *CreateListenerInput) string { } func (elbv2 *ELBV2) ModifyLoadBalancerDefaultAction(lbArn, targetGroupArn string) { - console.Debug("Setting ELB listener default action") - listeners := elbv2.GetListeners(lbArn) + for _, listener := range elbv2.GetListeners(lbArn) { + elbv2.ModifyListenerDefaultAction(listener.Arn, targetGroupArn) + } +} + +func (elbv2 *ELBV2) ModifyListenerDefaultAction(listenerArn, targetGroupArn string) { action := &awselbv2.Action{ TargetGroupArn: aws.String(targetGroupArn), Type: aws.String(awselbv2.ActionTypeEnumForward), } - for _, listener := range listeners { - elbv2.svc.ModifyListener( - &awselbv2.ModifyListenerInput{ - ListenerArn: aws.String(listener.Arn), - DefaultActions: []*awselbv2.Action{action}, - }, - ) - } + elbv2.svc.ModifyListener( + &awselbv2.ModifyListenerInput{ + ListenerArn: aws.String(listenerArn), + DefaultActions: []*awselbv2.Action{action}, + }, + ) } func (elbv2 *ELBV2) AddRule(lbArn, targetGroupArn string, rule Rule) {