Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions pkg/destroy/aws/iamhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
)

const (
ErrCodeAccessDeniedException = "AccessDeniedException"
)

type iamRoleSearch struct {
client *iam.IAM
filters []Filter
Expand All @@ -39,13 +43,21 @@ func (search *iamRoleSearch) find(ctx context.Context) (arns []string, names []s
// Unfortunately role.Tags is empty from ListRoles, so we need to query each one
response, err := search.client.GetRoleWithContext(ctx, &iam.GetRoleInput{RoleName: role.RoleName})
if err != nil {
if err.(awserr.Error).Code() == iam.ErrCodeNoSuchEntityException {
search.unmatched[*role.Arn] = exists
} else {
if lastError != nil {
search.logger.Debug(lastError)
var awsErr awserr.Error
if errors.As(err, &awsErr) {
switch awsErr.Code() {
case ErrCodeAccessDeniedException, iam.ErrCodeNoSuchEntityException:
// Installer does not have access to this IAM role or the
// the role does not exist.
// Ignore this IAM Role and donot report this error via
// lastError
search.unmatched[*role.Arn] = exists
default:
if lastError != nil {
search.logger.Debug(lastError)
}
lastError = errors.Wrapf(err, "get tags for %s", *role.Arn)
}
lastError = errors.Wrapf(err, "get tags for %s", *role.Arn)
}
} else {
role = response.Role
Expand Down