Skip to content

Commit

Permalink
resource/aws_cloudfront_distribution: Retry deletion on DistributionN…
Browse files Browse the repository at this point in the history
…otDisabled
  • Loading branch information
bflad committed Jan 17, 2018
1 parent 85b7eeb commit 188e60c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions aws/resource_aws_cloudfront_distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,19 @@ func resourceAwsCloudFrontDistributionDelete(d *schema.ResourceData, meta interf
IfMatch: aws.String(d.Get("etag").(string)),
}

_, err = conn.DeleteDistribution(params)
// Eventual consistency for "deployed" state
err = resource.Retry(1*time.Minute, func() *resource.RetryError {
_, err := conn.DeleteDistribution(params)
if err != nil {
if isAWSErr(err, cloudfront.ErrCodeDistributionNotDisabled, "The distribution you are trying to delete has not been disabled.") {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
return nil
})
if err != nil {
return err
return fmt.Errorf("CloudFront Distribution %s cannot be deleted: %s", d.Id(), err)
}

// Done
Expand Down

0 comments on commit 188e60c

Please sign in to comment.