Skip to content

Commit 87a76c8

Browse files
authored
Merge pull request ekristen#576 from Deofex/inaccessible-open-id-connect-providers
fix(OpenIDConnectProvider): inaccessible providers
2 parents 4d23d48 + 851facc commit 87a76c8

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

resources/iam-open-id-connect-provider.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ package resources
22

33
import (
44
"context"
5+
"errors"
56

7+
"github.com/aws/aws-sdk-go/aws/awserr"
68
"github.com/aws/aws-sdk-go/service/iam"
79
"github.com/aws/aws-sdk-go/service/iam/iamiface"
10+
"github.com/sirupsen/logrus"
811

912
"github.com/ekristen/libnuke/pkg/registry"
1013
"github.com/ekristen/libnuke/pkg/resource"
@@ -39,14 +42,25 @@ func (l *IAMOpenIDConnectProviderLister) List(_ context.Context, o interface{})
3942
return nil, err
4043
}
4144

45+
var inaccessibleOpenIDConnectProvider bool
46+
4247
for _, out := range resp.OpenIDConnectProviderList {
4348
params := &iam.GetOpenIDConnectProviderInput{
4449
OpenIDConnectProviderArn: out.Arn,
4550
}
4651
resp, err := svc.GetOpenIDConnectProvider(params)
4752

4853
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+
}
5064
}
5165

5266
resources = append(resources, &IAMOpenIDConnectProvider{
@@ -56,6 +70,10 @@ func (l *IAMOpenIDConnectProviderLister) List(_ context.Context, o interface{})
5670
})
5771
}
5872

73+
if inaccessibleOpenIDConnectProvider {
74+
logrus.Warn("one or more OpenIDConnectProviders were inaccessible, debug logging will contain more information")
75+
}
76+
5977
return resources, nil
6078
}
6179

0 commit comments

Comments
 (0)