Skip to content

Commit

Permalink
Merge pull request #4825 from hashicorp/b-aws-elb-listener-retry
Browse files Browse the repository at this point in the history
provider/aws: Retry Listener Creation for ELBs
  • Loading branch information
catsby committed Jan 25, 2016
2 parents 6ce5ade + 86ad4c4 commit 577618b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions builtin/providers/aws/resource_aws_elb.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,22 @@ func resourceAwsElbUpdate(d *schema.ResourceData, meta interface{}) error {
Listeners: add,
}

log.Printf("[DEBUG] ELB Create Listeners opts: %s", createListenersOpts)
_, err := elbconn.CreateLoadBalancerListeners(createListenersOpts)
// Occasionally AWS will error with a 'duplicate listener', without any
// other listeners on the ELB. Retry here to eliminate that.
err := resource.Retry(1*time.Minute, func() error {
log.Printf("[DEBUG] ELB Create Listeners opts: %s", createListenersOpts)
if _, err := elbconn.CreateLoadBalancerListeners(createListenersOpts); err != nil {
if awserr, ok := err.(awserr.Error); ok && awserr.Code() == "DuplicateListener" {
log.Printf("[DEBUG] Duplicate listener found for ELB (%s), retrying", d.Id())
return awserr
}

// Didn't recognize the error, so shouldn't retry.
return resource.RetryError{Err: err}
}
// Successful creation
return nil
})
if err != nil {
return fmt.Errorf("Failure adding new or updated ELB listeners: %s", err)
}
Expand Down

0 comments on commit 577618b

Please sign in to comment.