Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/aws_cloudfront_distribution: Allow final creation and update timeout retry for AWS Go SDK retries #7809

Merged
merged 1 commit into from
Mar 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions aws/resource_aws_cloudfront_distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,16 +699,25 @@ func resourceAwsCloudFrontDistributionCreate(d *schema.ResourceData, meta interf
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
var err error
resp, err = conn.CreateDistributionWithTags(params)

// ACM and IAM certificate eventual consistency
// InvalidViewerCertificate: The specified SSL certificate doesn't exist, isn't in us-east-1 region, isn't valid, or doesn't include a valid certificate chain.
if isAWSErr(err, cloudfront.ErrCodeInvalidViewerCertificate, "") {
return resource.RetryableError(err)
}

if err != nil {
// ACM and IAM certificate eventual consistency
// InvalidViewerCertificate: The specified SSL certificate doesn't exist, isn't in us-east-1 region, isn't valid, or doesn't include a valid certificate chain.
if isAWSErr(err, cloudfront.ErrCodeInvalidViewerCertificate, "") {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}

return nil
})

// Propagate AWS Go SDK retried error, if any
if isResourceTimeoutError(err) {
resp, err = conn.CreateDistributionWithTags(params)
}

if err != nil {
return fmt.Errorf("error creating CloudFront Distribution: %s", err)
}
Expand Down Expand Up @@ -785,16 +794,25 @@ func resourceAwsCloudFrontDistributionUpdate(d *schema.ResourceData, meta interf
// Handle eventual consistency issues
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
_, err := conn.UpdateDistribution(params)

// ACM and IAM certificate eventual consistency
// InvalidViewerCertificate: The specified SSL certificate doesn't exist, isn't in us-east-1 region, isn't valid, or doesn't include a valid certificate chain.
if isAWSErr(err, cloudfront.ErrCodeInvalidViewerCertificate, "") {
return resource.RetryableError(err)
}

if err != nil {
// ACM and IAM certificate eventual consistency
// InvalidViewerCertificate: The specified SSL certificate doesn't exist, isn't in us-east-1 region, isn't valid, or doesn't include a valid certificate chain.
if isAWSErr(err, cloudfront.ErrCodeInvalidViewerCertificate, "") {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}

return nil
})

// Propagate AWS Go SDK retried error, if any
if isResourceTimeoutError(err) {
_, err = conn.UpdateDistribution(params)
}

if err != nil {
return fmt.Errorf("error updating CloudFront Distribution (%s): %s", d.Id(), err)
}
Expand Down