diff --git a/aws/internal/service/securityhub/errors.go b/aws/internal/service/securityhub/errors.go new file mode 100644 index 00000000000..15aca496346 --- /dev/null +++ b/aws/internal/service/securityhub/errors.go @@ -0,0 +1,5 @@ +package securityhub + +const ( + ErrCodeBadRequestException = "BadRequestException" +) diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index b630da3fcf8..6995d6bdf13 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -6,8 +6,10 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/securityhub" + "github.com/hashicorp/aws-sdk-go-base/tfawserr" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + tfsecurityhub "github.com/terraform-providers/terraform-provider-aws/aws/internal/service/securityhub" ) func testAccAWSSecurityHubMember_basic(t *testing.T) { @@ -99,11 +101,16 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { AccountIds: []*string{aws.String(rs.Primary.ID)}, }) + if tfawserr.ErrCodeEquals(err, tfsecurityhub.ErrCodeBadRequestException) { + continue + } + + if tfawserr.ErrCodeEquals(err, securityhub.ErrCodeResourceNotFoundException) { + continue + } + if err != nil { - if isAWSErr(err, securityhub.ErrCodeResourceNotFoundException, "") { - return nil - } - return err + return fmt.Errorf("error getting Security Hub Member (%s): %w", rs.Primary.ID, err) } if len(resp.Members) != 0 {