Fix no such entity check for iam profiles and roles

This commit is contained in:
Ole Markus With 2022-08-21 07:29:30 +02:00
parent 87de208fcd
commit 084ecac2bb
1 changed files with 3 additions and 3 deletions

View File

@ -2008,7 +2008,7 @@ func ListIAMRoles(cloud fi.Cloud, clusterName string) ([]*resources.Resource, er
klog.Warningf("failed to determine ownership of %q: %v", *r.RoleName, awserror) klog.Warningf("failed to determine ownership of %q: %v", *r.RoleName, awserror)
return true return true
} else if awserror.StatusCode() == 404 { } else if awsup.AWSErrorCode(err) == iam.ErrCodeNoSuchEntityException {
klog.Warningf("could not find instance profile %q. Resource may already have been deleted: %v", name, awserror) klog.Warningf("could not find instance profile %q. Resource may already have been deleted: %v", name, awserror)
return true return true
} }
@ -2093,8 +2093,8 @@ func ListIAMInstanceProfiles(cloud fi.Cloud, clusterName string) ([]*resources.R
getRequest := &iam.GetInstanceProfileInput{InstanceProfileName: p.InstanceProfileName} getRequest := &iam.GetInstanceProfileInput{InstanceProfileName: p.InstanceProfileName}
profileOutput, err := c.IAM().GetInstanceProfile(getRequest) profileOutput, err := c.IAM().GetInstanceProfile(getRequest)
if err != nil { if err != nil {
if awserror, ok := err.(awserr.RequestFailure); ok { if awserror, ok := err.(awserr.Error); ok {
if awserror.StatusCode() == 404 { if awserror.Code() == iam.ErrCodeNoSuchEntityException {
klog.Warningf("could not find instance profile %q. Resource may already have been deleted: %v", *p.InstanceProfileName, awserror) klog.Warningf("could not find instance profile %q. Resource may already have been deleted: %v", *p.InstanceProfileName, awserror)
} }
} }