@@ -2,9 +2,12 @@ package resources
2
2
3
3
import (
4
4
"context"
5
+ "errors"
5
6
7
+ "github.com/aws/aws-sdk-go/aws/awserr"
6
8
"github.com/aws/aws-sdk-go/service/iam"
7
9
"github.com/aws/aws-sdk-go/service/iam/iamiface"
10
+ "github.com/sirupsen/logrus"
8
11
9
12
"github.com/ekristen/libnuke/pkg/registry"
10
13
"github.com/ekristen/libnuke/pkg/resource"
@@ -39,14 +42,25 @@ func (l *IAMOpenIDConnectProviderLister) List(_ context.Context, o interface{})
39
42
return nil , err
40
43
}
41
44
45
+ var inaccessibleOpenIDConnectProvider bool
46
+
42
47
for _ , out := range resp .OpenIDConnectProviderList {
43
48
params := & iam.GetOpenIDConnectProviderInput {
44
49
OpenIDConnectProviderArn : out .Arn ,
45
50
}
46
51
resp , err := svc .GetOpenIDConnectProvider (params )
47
52
48
53
if err != nil {
49
- return nil , err
54
+ var awsError awserr.Error
55
+ if errors .As (err , & awsError ) {
56
+ if awsError .Code () == "AccessDenied" {
57
+ inaccessibleOpenIDConnectProvider = true
58
+ logrus .WithError (err ).WithField ("arn" , out .Arn ).Debug ("inaccessible openIDConnectProvider" )
59
+ continue
60
+ } else {
61
+ logrus .WithError (err ).WithField ("arn" , out .Arn ).Error ("unable to list openIDConnectProvider" )
62
+ }
63
+ }
50
64
}
51
65
52
66
resources = append (resources , & IAMOpenIDConnectProvider {
@@ -56,6 +70,10 @@ func (l *IAMOpenIDConnectProviderLister) List(_ context.Context, o interface{})
56
70
})
57
71
}
58
72
73
+ if inaccessibleOpenIDConnectProvider {
74
+ logrus .Warn ("one or more OpenIDConnectProviders were inaccessible, debug logging will contain more information" )
75
+ }
76
+
59
77
return resources , nil
60
78
}
61
79
0 commit comments