Skip to content

Commit

Permalink
Merge pull request #13009 from camlow325/fix_retry_for_tag_update_aft…
Browse files Browse the repository at this point in the history
…er_s3_bucket_creation

resource/aws_s3_bucket: Retry on GetBucketTagging 404 Errors
  • Loading branch information
ewbankkit authored Aug 30, 2021
2 parents dea5008 + 2c34a42 commit ac372ba
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions aws/awserr.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package aws

import (
"errors"
"time"

"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/hashicorp/aws-sdk-go-base/tfawserr"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/tfresource"
Expand Down Expand Up @@ -38,31 +36,3 @@ func retryOnAwsCode(code string, f func() (interface{}, error)) (interface{}, er

return resp, err
}

// RetryOnAwsCodes retries AWS error codes for one minute
// Note: This function will be moved out of the aws package in the future.
func RetryOnAwsCodes(codes []string, f func() (interface{}, error)) (interface{}, error) {
var resp interface{}
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
var err error
resp, err = f()
if err != nil {
var awsErr awserr.Error
if errors.As(err, &awsErr) {
for _, code := range codes {
if awsErr.Code() == code {
return resource.RetryableError(err)
}
}
}
return resource.NonRetryableError(err)
}
return nil
})

if tfresource.TimedOut(err) {
resp, err = f()
}

return resp, err
}

0 comments on commit ac372ba

Please sign in to comment.