Skip to content

Commit

Permalink
Adds sweeper for aws_m2_application
Browse files Browse the repository at this point in the history
  • Loading branch information
gdavison committed Jun 26, 2024
1 parent 65dca0b commit 67ce9a8
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions internal/service/m2/sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,38 @@ import (
)

func RegisterSweepers() {
sweep.Register("aws_m2_application", sweepApplications)

sweep.Register("aws_m2_environment", sweepEnvironments)
}

func sweepApplications(ctx context.Context, client *conns.AWSClient) ([]sweep.Sweepable, error) {
conn := client.M2Client(ctx)

var sweepResources []sweep.Sweepable

pages := m2.NewListApplicationsPaginator(conn, &m2.ListApplicationsInput{})
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)
if awsv2.SkipSweepError(err) {
tflog.Warn(ctx, "Skipping sweeper", map[string]any{
"error": err.Error(),
})
return nil, nil
}
if err != nil {
return nil, err
}

for _, application := range page.Applications {
sweepResources = append(sweepResources, framework.NewSweepResource(newApplicationResource, client,
framework.NewAttribute(names.AttrID, aws.ToString(application.ApplicationId))))
}
}

return sweepResources, nil
}

func sweepEnvironments(ctx context.Context, client *conns.AWSClient) ([]sweep.Sweepable, error) {
conn := client.M2Client(ctx)

Expand Down

0 comments on commit 67ce9a8

Please sign in to comment.