diff --git a/internal/service/sagemaker/sweep.go b/internal/service/sagemaker/sweep.go index d0a9b5e7505..e001f7c946e 100644 --- a/internal/service/sagemaker/sweep.go +++ b/internal/service/sagemaker/sweep.go @@ -11,7 +11,9 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/sagemaker" awstypes "github.com/aws/aws-sdk-go-v2/service/sagemaker/types" + "github.com/hashicorp/aws-sdk-go-base/v2/tfawserr" "github.com/hashicorp/go-multierror" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/sweep" "github.com/hashicorp/terraform-provider-aws/internal/sweep/awsv2" @@ -1131,15 +1133,23 @@ func sweepHubs(region string) error { } conn := client.SageMakerClient(ctx) - sweepResources := make([]sweep.Sweepable, 0) - in := &sagemaker.ListHubsInput{} + var sweepResources []sweep.Sweepable + in := sagemaker.ListHubsInput{} for { - out, err := conn.ListHubs(ctx, in) + out, err := conn.ListHubs(ctx, &in) if awsv2.SkipSweepError(err) { log.Printf("[WARN] Skipping Sagemaker Hubs sweep for %s: %s", region, err) return nil } + // The Sagemaker API returns this in unsupported regions + if tfawserr.ErrCodeEquals(err, "ThrottlingException") { + tflog.Warn(ctx, "Skipping sweeper", map[string]any{ + "skip_reason": "Unsupported region", + "error": err.Error(), + }) + return nil + } if err != nil { return fmt.Errorf("error retrieving Sagemaker Hubs: %w", err) }