diff --git a/internal/service/elasticsearch/domain_test.go b/internal/service/elasticsearch/domain_test.go index 1cab77f4c27..e0eb3b5362e 100644 --- a/internal/service/elasticsearch/domain_test.go +++ b/internal/service/elasticsearch/domain_test.go @@ -3,7 +3,6 @@ package elasticsearch_test import ( "fmt" "regexp" - "strings" "testing" "time" @@ -12,7 +11,6 @@ import ( "github.com/aws/aws-sdk-go/service/cognitoidentityprovider" elasticsearch "github.com/aws/aws-sdk-go/service/elasticsearchservice" "github.com/aws/aws-sdk-go/service/elb" - "github.com/aws/aws-sdk-go/service/iam" sdkacctest "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -1761,35 +1759,7 @@ func testAccGetValidStartAtTime(t *testing.T, timeUntilStart string) string { } func testAccPreCheckIAMServiceLinkedRole(t *testing.T) { - conn := acctest.Provider.Meta().(*conns.AWSClient).IAMConn - dnsSuffix := acctest.Provider.Meta().(*conns.AWSClient).DNSSuffix - - input := &iam.ListRolesInput{ - PathPrefix: aws.String("/aws-service-role/es."), - } - - var role *iam.Role - err := conn.ListRolesPages(input, func(page *iam.ListRolesOutput, lastPage bool) bool { - for _, r := range page.Roles { - if strings.HasPrefix(aws.StringValue(r.Path), "/aws-service-role/es.") { - role = r - } - } - - return !lastPage - }) - - if acctest.PreCheckSkipError(err) { - t.Skipf("skipping acceptance testing: %s", err) - } - - if err != nil { - t.Fatalf("unexpected PreCheck error: %s", err) - } - - if role == nil { - t.Fatalf("missing IAM Service Linked Role (es.%s), please create it in the AWS account and retry", dnsSuffix) - } + acctest.PreCheckIAMServiceLinkedRole(t, "/aws-service-role/es") } func testAccDomainConfig_basic(rName string) string {