Skip to content

Commit

Permalink
Add retry in test check as well
Browse files Browse the repository at this point in the history
  • Loading branch information
anGie44 committed Feb 6, 2022
1 parent 195ef4f commit 865c3ca
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/service/s3/bucket_cors_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
tfs3 "github.com/hashicorp/terraform-provider-aws/internal/service/s3"
"github.com/hashicorp/terraform-provider-aws/internal/verify"
)

func TestAccS3BucketCorsConfiguration_basic(t *testing.T) {
Expand Down Expand Up @@ -283,13 +284,15 @@ func testAccCheckBucketCorsConfigurationExists(resourceName string) resource.Tes
input.ExpectedBucketOwner = aws.String(expectedBucketOwner)
}

output, err := conn.GetBucketCors(input)
corsResponse, err := verify.RetryOnAWSCode(tfs3.ErrCodeNoSuchCORSConfiguration, func() (interface{}, error) {
return conn.GetBucketCors(input)
})

if err != nil {
return fmt.Errorf("error getting S3 Bucket CORS configuration (%s): %w", rs.Primary.ID, err)
}

if output == nil || len(output.CORSRules) == 0 {
if output, ok := corsResponse.(*s3.GetBucketCorsOutput); !ok || output == nil || len(output.CORSRules) == 0 {
return fmt.Errorf("S3 Bucket CORS configuration (%s) not found", rs.Primary.ID)
}

Expand Down

0 comments on commit 865c3ca

Please sign in to comment.