Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Only change listener default action once
Browse files Browse the repository at this point in the history
  • Loading branch information
jpignata committed Jan 3, 2018
1 parent d39f826 commit ed57d12
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cmd/service_destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func destroyService(operation *ServiceDestroyOperation) {
)
}

elbv2.ModifyLoadBalancerDefaultAction(loadBalancer.Arn, defaultTargetGroupArn)
elbv2.ModifyListenerDefaultAction(listener.Arn, defaultTargetGroupArn)
} else {
elbv2.DeleteRule(rule.Arn)
}
Expand Down
22 changes: 12 additions & 10 deletions elbv2/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ed57d12

Please sign in to comment.