Skip to content

Commit 484aeec

Browse files
Merge pull request openshift#7180 from sadasu/aws-sts-uninstall
OCPBUGS-1769: Ignore IAM Roles that the Installer is not authorized to access
2 parents ee0ba30 + 4652b87 commit 484aeec

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

pkg/destroy/aws/iamhelpers.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package aws
22

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

67
"github.com/aws/aws-sdk-go/aws"
78
"github.com/aws/aws-sdk-go/aws/arn"
@@ -13,11 +14,6 @@ import (
1314
"k8s.io/apimachinery/pkg/util/sets"
1415
)
1516

16-
const (
17-
// ErrCodeAccessDeniedException is the access denied error code returned by IAM.
18-
ErrCodeAccessDeniedException = "AccessDeniedException"
19-
)
20-
2117
type iamRoleSearch struct {
2218
client *iam.IAM
2319
filters []Filter
@@ -46,10 +42,14 @@ func (search *iamRoleSearch) find(ctx context.Context) (arns []string, names []s
4642
if err != nil {
4743
var awsErr awserr.Error
4844
if errors.As(err, &awsErr) {
49-
switch awsErr.Code() {
50-
case ErrCodeAccessDeniedException, iam.ErrCodeNoSuchEntityException:
51-
// Installer does not have access to this IAM role or the
52-
// the role does not exist.
45+
switch {
46+
case awsErr.Code() == iam.ErrCodeNoSuchEntityException:
47+
// The role does not exist.
48+
// Ignore this IAM Role and donot report this error via
49+
// lastError
50+
search.unmatched[*role.Arn] = exists
51+
case strings.Contains(err.Error(), "AccessDenied"):
52+
// Installer does not have access to this IAM role
5353
// Ignore this IAM Role and donot report this error via
5454
// lastError
5555
search.unmatched[*role.Arn] = exists

0 commit comments

Comments
 (0)