provider/aws: Retry Listener Creation for ELBs

This commit is contained in:
clint shryock 2016-01-25 11:38:04 -06:00
parent e865c342cc
commit 86ad4c4340
1 changed files with 16 additions and 2 deletions

View File

@ -420,8 +420,22 @@ func resourceAwsElbUpdate(d *schema.ResourceData, meta interface{}) error {
Listeners: add,
}
// 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)
_, err := elbconn.CreateLoadBalancerListeners(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)
}