diff --git a/internal/service/devopsguru/devopsguru_test.go b/internal/service/devopsguru/devopsguru_test.go index 65b954cc8ab..0caf6ab696d 100644 --- a/internal/service/devopsguru/devopsguru_test.go +++ b/internal/service/devopsguru/devopsguru_test.go @@ -4,9 +4,15 @@ package devopsguru_test import ( + "context" + "errors" + "net" + "strings" "testing" + "github.com/aws/aws-sdk-go-v2/service/devopsguru" "github.com/hashicorp/terraform-provider-aws/internal/acctest" + "github.com/hashicorp/terraform-provider-aws/internal/conns" ) func TestAccDevOpsGuru_serial(t *testing.T) { @@ -45,3 +51,23 @@ func TestAccDevOpsGuru_serial(t *testing.T) { acctest.RunSerialTests2Levels(t, testCases, 0) } + +func testAccPreCheck(ctx context.Context, t *testing.T) { + conn := acctest.Provider.Meta().(*conns.AWSClient).DevOpsGuruClient(ctx) + + _, err := conn.DescribeAccountHealth(ctx, &devopsguru.DescribeAccountHealthInput{}) + + if acctest.PreCheckSkipError(err) { + t.Skipf("skipping acceptance testing: %s", err) + } + // In GovCloud partitions, API calls trigger an operation error + var netOpErr *net.OpError + if errors.As(err, &netOpErr) { + if strings.Contains(netOpErr.Error(), "no such host") { + t.Skipf("skipping acceptance testing: %s", err) + } + } + if err != nil { + t.Fatalf("unexpected PreCheck error: %s", err) + } +} diff --git a/internal/service/devopsguru/event_sources_config_test.go b/internal/service/devopsguru/event_sources_config_test.go index 641ffec6572..2f07185e04d 100644 --- a/internal/service/devopsguru/event_sources_config_test.go +++ b/internal/service/devopsguru/event_sources_config_test.go @@ -28,6 +28,7 @@ func testAccEventSourcesConfig_basic(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.DevOpsGuruEndpointID) + testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.DevOpsGuruServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -60,6 +61,7 @@ func testAccEventSourcesConfig_disappears(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.DevOpsGuruEndpointID) + testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.DevOpsGuruServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/devopsguru/notification_channel_data_source_test.go b/internal/service/devopsguru/notification_channel_data_source_test.go index 2bb7c07d41d..ca54c49eb67 100644 --- a/internal/service/devopsguru/notification_channel_data_source_test.go +++ b/internal/service/devopsguru/notification_channel_data_source_test.go @@ -23,6 +23,7 @@ func testAccNotificationChannelDataSource_basic(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.DevOpsGuruEndpointID) + testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.DevOpsGuruServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/devopsguru/notification_channel_test.go b/internal/service/devopsguru/notification_channel_test.go index f4485875ed8..88293ec168a 100644 --- a/internal/service/devopsguru/notification_channel_test.go +++ b/internal/service/devopsguru/notification_channel_test.go @@ -33,6 +33,7 @@ func testAccNotificationChannel_basic(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.DevOpsGuruEndpointID) + testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.DevOpsGuruServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -65,6 +66,7 @@ func testAccNotificationChannel_disappears(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.DevOpsGuruEndpointID) + testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.DevOpsGuruServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -95,6 +97,7 @@ func testAccNotificationChannel_filters(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.DevOpsGuruEndpointID) + testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.DevOpsGuruServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/devopsguru/resource_collection_data_source_test.go b/internal/service/devopsguru/resource_collection_data_source_test.go index ace07ac60f7..85c67dc6ab2 100644 --- a/internal/service/devopsguru/resource_collection_data_source_test.go +++ b/internal/service/devopsguru/resource_collection_data_source_test.go @@ -20,6 +20,7 @@ func testAccResourceCollectionDataSource_basic(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.DevOpsGuruEndpointID) + testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.DevOpsGuruServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/devopsguru/resource_collection_test.go b/internal/service/devopsguru/resource_collection_test.go index 05f5cead2d9..1009b8295fe 100644 --- a/internal/service/devopsguru/resource_collection_test.go +++ b/internal/service/devopsguru/resource_collection_test.go @@ -38,6 +38,7 @@ func testAccResourceCollection_basic(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.DevOpsGuruEndpointID) + testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.DevOpsGuruServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -71,6 +72,7 @@ func testAccResourceCollection_disappears(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.DevOpsGuruEndpointID) + testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.DevOpsGuruServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -99,6 +101,7 @@ func testAccResourceCollection_cloudformation(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.DevOpsGuruEndpointID) + testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.DevOpsGuruServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -134,6 +137,7 @@ func testAccResourceCollection_tags(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.DevOpsGuruEndpointID) + testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.DevOpsGuruServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -170,6 +174,7 @@ func testAccResourceCollection_tagsAllResources(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.DevOpsGuruEndpointID) + testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.DevOpsGuruServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/devopsguru/service_integration_test.go b/internal/service/devopsguru/service_integration_test.go index 02fc2bbd537..f735941187d 100644 --- a/internal/service/devopsguru/service_integration_test.go +++ b/internal/service/devopsguru/service_integration_test.go @@ -29,6 +29,7 @@ func testAccServiceIntegration_basic(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.DevOpsGuruEndpointID) + testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.DevOpsGuruServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -72,6 +73,7 @@ func testAccServiceIntegration_kms(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.DevOpsGuruEndpointID) + testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.DevOpsGuruServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,