{"record":{"id":"505e07390c8060bc","repo":"kubernetes/kops","slug":"error-deleting-iam-instance-profile-q-v","errorCode":null,"errorMessage":"error deleting IAM instance profile %q: %v","messagePattern":"error deleting IAM instance profile %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/aws/aws.go","lineNumber":2063,"sourceCode":"\t\t\t\tInstanceProfileName: profile.InstanceProfileName,\n\t\t\t\tRoleName:            role.RoleName,\n\t\t\t}\n\t\t\t_, err := c.IAM().RemoveRoleFromInstanceProfile(ctx, request)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error removing role %q from IAM instance profile %q: %v\", aws.ToString(role.RoleName), name, err)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Delete the instance profile\n\t{\n\t\tklog.V(2).Infof(\"Deleting IAM instance profile %q\", name)\n\t\trequest := &iam.DeleteInstanceProfileInput{\n\t\t\tInstanceProfileName: profile.InstanceProfileName,\n\t\t}\n\t\t_, err := c.IAM().DeleteInstanceProfile(ctx, request)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error deleting IAM instance profile %q: %v\", name, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc ListIAMInstanceProfiles(cloud fi.Cloud, vpcID, clusterName string) ([]*resources.Resource, error) {\n\tctx := context.TODO()\n\tc := cloud.(awsup.AWSCloud)\n\n\tvar profiles []iamtypes.InstanceProfile\n\townershipTag := \"kubernetes.io/cluster/\" + clusterName\n\n\trequest := &iam.ListInstanceProfilesInput{}\n\tpaginator := iam.NewListInstanceProfilesPaginator(c.IAM(), request)\n\tfor paginator.HasMorePages() {\n\t\tpage, err := paginator.NextPage(ctx)\n\t\tif err != nil {","sourceCodeStart":2045,"sourceCodeEnd":2081,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/aws/aws.go#L2045-L2081","documentation":"During AWS cluster deletion, after detaching roles, the code calls iam.DeleteInstanceProfile for the cluster's instance profile; this wraps that call's failure. It fires when AWS refuses to delete the profile — typically because roles are still attached, or IAM permissions are missing; the profile name and AWS error are included.","triggerScenarios":"Thrown at pkg/resources/aws/aws.go:2063 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check iam:DeleteInstanceProfile permission","Ensure no EC2 instances still reference the instance profile, then retry","Inspect the wrapped error; NoSuchEntity means it was already deleted"],"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-12T07:17:12.445Z"}