diff --git a/internal/acctest/acctest.go b/internal/acctest/acctest.go index 5400dc4ace00..241ec80a435f 100644 --- a/internal/acctest/acctest.go +++ b/internal/acctest/acctest.go @@ -9,6 +9,7 @@ import ( "errors" "fmt" "log" + "net" "os" "reflect" "regexp" @@ -1733,6 +1734,10 @@ func PreCheckSkipError(err error) bool { if tfawserr.ErrCodeEquals(err, "ForbiddenException") { return true } + // Ignore missing API endpoints + if errs.IsA[*net.DNSError](err) { + return true + } return false } diff --git a/internal/service/devopsguru/devopsguru_test.go b/internal/service/devopsguru/devopsguru_test.go index 65b954cc8ab3..f806a1297d9d 100644 --- a/internal/service/devopsguru/devopsguru_test.go +++ b/internal/service/devopsguru/devopsguru_test.go @@ -4,9 +4,12 @@ package devopsguru_test import ( + "context" "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 +48,16 @@ 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) + } + 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 641ffec65725..2f07185e04d9 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 2bb7c07d41d6..ca54c49eb679 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 f4485875ed8d..88293ec168aa 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 ace07ac60f7d..85c67dc6ab22 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 05f5cead2d90..1009b8295fe8 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 02fc2bbd5371..f735941187d2 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,