Skip to content

Commit

Permalink
Merge pull request hashicorp#40175 from hashicorp/td-sweep-sagemaker-hub
Browse files Browse the repository at this point in the history
sweeper/aws_sagemaker_hub: Skip sweeper in unsupported regions
  • Loading branch information
gdavison authored Nov 18, 2024
2 parents 2bbd9b3 + 86a5d94 commit c941f3b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions internal/service/sagemaker/sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit c941f3b

Please sign in to comment.