Skip to content

Commit 67ce9a8

Browse files
committed
Adds sweeper for aws_m2_application
1 parent 65dca0b commit 67ce9a8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

internal/service/m2/sweep.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,38 @@ import (
1717
)
1818

1919
func RegisterSweepers() {
20+
sweep.Register("aws_m2_application", sweepApplications)
21+
2022
sweep.Register("aws_m2_environment", sweepEnvironments)
2123
}
2224

25+
func sweepApplications(ctx context.Context, client *conns.AWSClient) ([]sweep.Sweepable, error) {
26+
conn := client.M2Client(ctx)
27+
28+
var sweepResources []sweep.Sweepable
29+
30+
pages := m2.NewListApplicationsPaginator(conn, &m2.ListApplicationsInput{})
31+
for pages.HasMorePages() {
32+
page, err := pages.NextPage(ctx)
33+
if awsv2.SkipSweepError(err) {
34+
tflog.Warn(ctx, "Skipping sweeper", map[string]any{
35+
"error": err.Error(),
36+
})
37+
return nil, nil
38+
}
39+
if err != nil {
40+
return nil, err
41+
}
42+
43+
for _, application := range page.Applications {
44+
sweepResources = append(sweepResources, framework.NewSweepResource(newApplicationResource, client,
45+
framework.NewAttribute(names.AttrID, aws.ToString(application.ApplicationId))))
46+
}
47+
}
48+
49+
return sweepResources, nil
50+
}
51+
2352
func sweepEnvironments(ctx context.Context, client *conns.AWSClient) ([]sweep.Sweepable, error) {
2453
conn := client.M2Client(ctx)
2554

0 commit comments

Comments
 (0)