@@ -2,8 +2,11 @@ package resources
2
2
3
3
import (
4
4
"context"
5
+ "errors"
6
+ "strings"
7
+
8
+ "github.com/gotidy/ptr"
5
9
6
- "github.com/aws/aws-sdk-go/aws"
7
10
"github.com/aws/aws-sdk-go/service/accessanalyzer"
8
11
9
12
"github.com/ekristen/libnuke/pkg/registry"
@@ -30,12 +33,10 @@ type AccessAnalyzerLister struct{}
30
33
func (l * AccessAnalyzerLister ) List (_ context.Context , o interface {}) ([]resource.Resource , error ) {
31
34
opts := o .(* nuke.ListerOpts )
32
35
svc := accessanalyzer .New (opts .Session )
36
+ resources := make ([]resource.Resource , 0 )
33
37
34
- params := & accessanalyzer.ListAnalyzersInput {
35
- Type : aws .String ("ACCOUNT" ),
36
- }
38
+ params := & accessanalyzer.ListAnalyzersInput {}
37
39
38
- resources := make ([]resource.Resource , 0 )
39
40
if err := svc .ListAnalyzersPages (params ,
40
41
func (page * accessanalyzer.ListAnalyzersOutput , lastPage bool ) bool {
41
42
for _ , analyzer := range page .Analyzers {
@@ -44,6 +45,7 @@ func (l *AccessAnalyzerLister) List(_ context.Context, o interface{}) ([]resourc
44
45
ARN : analyzer .Arn ,
45
46
Name : analyzer .Name ,
46
47
Status : analyzer .Status ,
48
+ Type : analyzer .Type ,
47
49
Tags : analyzer .Tags ,
48
50
})
49
51
}
@@ -60,9 +62,17 @@ type AccessAnalyzer struct {
60
62
ARN * string `description:"The ARN of the analyzer"`
61
63
Name * string `description:"The name of the analyzer"`
62
64
Status * string `description:"The status of the analyzer"`
65
+ Type * string `description:"The type of the analyzer"`
63
66
Tags map [string ]* string `description:"The tags of the analyzer"`
64
67
}
65
68
69
+ func (r * AccessAnalyzer ) Filter () error {
70
+ if strings .Contains (ptr .ToString (r .Name ), "ORGANIZATION" ) {
71
+ return errors .New ("cannot delete organization analyzer" )
72
+ }
73
+ return nil
74
+ }
75
+
66
76
func (r * AccessAnalyzer ) Remove (_ context.Context ) error {
67
77
_ , err := r .svc .DeleteAnalyzer (& accessanalyzer.DeleteAnalyzerInput {AnalyzerName : r .Name })
68
78
0 commit comments