Skip to content

Commit

Permalink
Merge pull request #3034 from terraform-providers/b-aws_cloudfront_di…
Browse files Browse the repository at this point in the history
…stribution-delete-retries

resource/aws_cloudfront_distribution: Retry deletion on DistributionNotDisabled
  • Loading branch information
bflad authored Jan 18, 2018
2 parents f217f77 + 188e60c commit 0c87e9a
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 0c87e9a

Please sign in to comment.