{"record":{"id":"6a6d6a54f8e53dcf","repo":"kubernetes/kops","slug":"error-removing-role-q-from-iam-instance-profile","errorCode":null,"errorMessage":"error removing role %q from IAM instance profile %q: %v","messagePattern":"error removing role %q from IAM instance profile %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/aws/aws.go","lineNumber":2050,"sourceCode":"\nfunc DeleteIAMInstanceProfile(cloud fi.Cloud, r *resources.Resource) error {\n\tctx := context.TODO()\n\tc := cloud.(awsup.AWSCloud)\n\n\tprofile := r.Obj.(iamtypes.InstanceProfile)\n\tname := aws.ToString(profile.InstanceProfileName)\n\n\t// Remove roles\n\t{\n\t\tfor _, role := range profile.Roles {\n\t\t\tklog.V(2).Infof(\"Removing role %q from IAM instance profile %q\", aws.ToString(role.RoleName), name)\n\t\t\trequest := &iam.RemoveRoleFromInstanceProfileInput{\n\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}","sourceCodeStart":2032,"sourceCodeEnd":2068,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/aws/aws.go#L2032-L2068","documentation":"Fires in DeleteIAMInstanceProfile when iam.RemoveRoleFromInstanceProfile fails while stripping roles from the instance profile prior to deletion — permissions, throttling, or a concurrently modified profile.","triggerScenarios":"Thrown at pkg/resources/aws/aws.go:2050 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check iam:RemoveRoleFromInstanceProfile permission","Retry after transient errors; the profile may have been modified concurrently","Ensure no EC2 instances are actively using the profile"],"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"}