Skip to content

Commit

Permalink
resource/aws_lb_listener: Retry CertificateNotFound errors on update …
Browse files Browse the repository at this point in the history
…for IAM eventual consistency
  • Loading branch information
bflad committed Mar 23, 2018
1 parent afd69d0 commit 941ce36
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions aws/resource_aws_lb_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,12 @@ func resourceAwsLbListenerCreate(d *schema.ResourceData, meta interface{}) error
var err error
log.Printf("[DEBUG] Creating LB listener for ARN: %s", d.Get("load_balancer_arn").(string))
resp, err = elbconn.CreateListener(params)
if awsErr, ok := err.(awserr.Error); ok {
if awsErr.Code() == "CertificateNotFound" {
log.Printf("[WARN] Got an error while trying to create LB listener for ARN: %s: %s", lbArn, err)
if err != nil {
if isAWSErr(err, elbv2.ErrCodeCertificateNotFoundException, "") {
return resource.RetryableError(err)
}
}
if err != nil {
return resource.NonRetryableError(err)
}

return nil
})

Expand Down Expand Up @@ -232,7 +228,16 @@ func resourceAwsLbListenerUpdate(d *schema.ResourceData, meta interface{}) error
}
}

_, err := elbconn.ModifyListener(params)
err := resource.Retry(5*time.Minute, func() *resource.RetryError {
_, err := elbconn.ModifyListener(params)
if err != nil {
if isAWSErr(err, elbv2.ErrCodeCertificateNotFoundException, "") {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
return nil
})
if err != nil {
return errwrap.Wrapf("Error modifying LB Listener: {{err}}", err)
}
Expand Down

0 comments on commit 941ce36

Please sign in to comment.