{"record":{"id":"e5d7f9e4d477687c","repo":"kubernetes/kops","slug":"error-listing-iam-roles-v","errorCode":null,"errorMessage":"error listing IAM roles: %v","messagePattern":"error listing IAM roles: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/aws/aws.go","lineNumber":1998,"sourceCode":"\t}\n\n\treturn nil\n}\n\nfunc ListIAMRoles(cloud fi.Cloud, vpcID, clusterName string) ([]*resources.Resource, error) {\n\tctx := context.TODO()\n\tc := cloud.(awsup.AWSCloud)\n\n\tvar resourceTrackers []*resources.Resource\n\t// Find roles owned by the cluster\n\t{\n\t\townershipTag := \"kubernetes.io/cluster/\" + clusterName\n\t\trequest := &iam.ListRolesInput{}\n\t\tpaginator := iam.NewListRolesPaginator(c.IAM(), request)\n\t\tfor paginator.HasMorePages() {\n\t\t\tpage, err := paginator.NextPage(ctx)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error listing IAM roles: %v\", err)\n\t\t\t}\n\t\t\tfor _, r := range page.Roles {\n\t\t\t\tname := aws.ToString(r.RoleName)\n\n\t\t\t\tgetRequest := &iam.GetRoleInput{RoleName: r.RoleName}\n\t\t\t\troleOutput, err := c.IAM().GetRole(ctx, getRequest)\n\t\t\t\tif err != nil {\n\t\t\t\t\tif awsup.IsIAMNoSuchEntityException(err) {\n\t\t\t\t\t\tklog.Warningf(\"could not find role %q. Resource may already have been deleted: %v\", name, err)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t} else if awsup.AWSErrorCode(err) == \"403\" {\n\t\t\t\t\t\tklog.Warningf(\"failed to determine ownership of %q: %v\", name, err)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\treturn nil, fmt.Errorf(\"calling IAM GetRole on %s: %w\", name, err)\n\t\t\t\t}\n\t\t\t\tfor _, tag := range roleOutput.Role.Tags {\n\t\t\t\t\tif fi.ValueOf(tag.Key) == ownershipTag && fi.ValueOf(tag.Value) == \"owned\" {","sourceCodeStart":1980,"sourceCodeEnd":2016,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/aws/aws.go#L1980-L2016","documentation":"Fires in ListIAMRoles when paginated iam.ListRoles fails during cluster resource discovery — an AWS API, credentials, or throttling failure while enumerating roles, before cluster ownership tags are even checked.","triggerScenarios":"Thrown at pkg/resources/aws/aws.go:1998 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify IAM credentials and iam:ListRoles permission","Retry after throttling errors","Check network/proxy connectivity to the IAM endpoint"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}