Skip to content

Commit

Permalink
Merge pull request #32465 from hashicorp/b-sweep-batch-job-definition
Browse files Browse the repository at this point in the history
sweep: `aws_batch_job_definition` sweeper was calling wrong resource implementation
  • Loading branch information
gdavison authored Jul 12, 2023
2 parents ae0c2c5 + 5c9ae72 commit 4e662e1
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions internal/service/batch/sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
multierror "github.com/hashicorp/go-multierror"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-provider-aws/internal/sweep"
"github.com/hashicorp/terraform-provider-aws/internal/sweep/sdk"
)

func init() {
Expand Down Expand Up @@ -141,15 +142,15 @@ func sweepComputeEnvironments(region string) error {
d := r.Data(nil)
d.SetId(name)

sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client))
sweepResources = append(sweepResources, sdk.NewSweepResource(r, d, client))
}

return !lastPage
})

if sweep.SkipSweepError(err) {
log.Printf("[WARN] Skipping Batch Compute Environment sweep for %s: %s", region, err)
return sweeperErrs.ErrorOrNil() // In case we have completed some pages, but had errors
return nil
}

if err != nil {
Expand All @@ -162,10 +163,6 @@ func sweepComputeEnvironments(region string) error {
sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error sweeping Batch Compute Environments (%s): %w", region, err))
}

if err := sweep.SweepOrchestrator(ctx, sweepResources); err != nil {
sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error sweeping Batch Compute Environments: %w", err))
}

return sweeperErrs.ErrorOrNil()
}

Expand All @@ -187,11 +184,11 @@ func sweepJobDefinitions(region string) error {
}

for _, v := range page.JobDefinitions {
r := ResourceSchedulingPolicy()
r := ResourceJobDefinition()
d := r.Data(nil)
d.SetId(aws.StringValue(v.JobDefinitionArn))

sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client))
sweepResources = append(sweepResources, sdk.NewSweepResource(r, d, client))
}

return !lastPage
Expand Down Expand Up @@ -236,7 +233,7 @@ func sweepJobQueues(region string) error {
d.SetId(aws.StringValue(v.JobQueueArn))
d.Set("name", v.JobQueueName)

sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client))
sweepResources = append(sweepResources, sdk.NewSweepResource(r, d, client))
}

return !lastPage
Expand Down Expand Up @@ -280,7 +277,7 @@ func sweepSchedulingPolicies(region string) error {
d := r.Data(nil)
d.SetId(aws.StringValue(v.Arn))

sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client))
sweepResources = append(sweepResources, sdk.NewSweepResource(r, d, client))
}

return !lastPage
Expand Down

0 comments on commit 4e662e1

Please sign in to comment.