Skip to content

Commit

Permalink
Retry acm certificate delete when in use exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
Genevieve LEsperance committed Mar 22, 2018
1 parent 61fe3b2 commit cf53d3a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion aws/resource_aws_acm_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,23 @@ func convertValidationOptions(certificate *acm.CertificateDetail) ([]map[string]
func resourceAwsAcmCertificateDelete(d *schema.ResourceData, meta interface{}) error {
acmconn := meta.(*AWSClient).acmconn

log.Printf("[INFO] Deleting ACM Certificate: %s", d.Id())

params := &acm.DeleteCertificateInput{
CertificateArn: aws.String(d.Id()),
}

_, err := acmconn.DeleteCertificate(params)
err := resource.Retry(10*time.Minute, func() *resource.RetryError {
_, err := acmconn.DeleteCertificate(params)
if err != nil {
if isAWSErr(err, acm.ErrCodeResourceInUseException, "") {
log.Printf("[WARN] Conflict deleting certificate in use: %s, retrying", err.Error())
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
return nil
})

if err != nil && !isAWSErr(err, acm.ErrCodeResourceNotFoundException, "") {
return fmt.Errorf("Error deleting certificate: %s", err)
Expand Down

0 comments on commit cf53d3a

Please sign in to comment.