@@ -17,9 +17,38 @@ import (
17
17
)
18
18
19
19
func RegisterSweepers () {
20
+ sweep .Register ("aws_m2_application" , sweepApplications )
21
+
20
22
sweep .Register ("aws_m2_environment" , sweepEnvironments )
21
23
}
22
24
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
+
23
52
func sweepEnvironments (ctx context.Context , client * conns.AWSClient ) ([]sweep.Sweepable , error ) {
24
53
conn := client .M2Client (ctx )
25
54
0 commit comments