{"record":{"id":"9282fd8a4c21e882","repo":"kubernetes/kops","slug":"error-deleting-iam-role-policy-q-q-v","errorCode":null,"errorMessage":"error deleting IAM role policy %q %q: %v","messagePattern":"error deleting IAM role policy %q %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/aws/aws.go","lineNumber":1953,"sourceCode":"\t\t\t\t\tklog.V(2).Infof(\"Got NoSuchEntity describing IAM RolePolicy %q; will treat as already-deleted\", roleName)\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\treturn fmt.Errorf(\"error listing IAM role policies for %q: %v\", roleName, err)\n\t\t\t}\n\t\t\tattachedPolicies = append(attachedPolicies, page.AttachedPolicies...)\n\t\t}\n\t}\n\n\t// Delete inline policies\n\tfor _, policyName := range policyNames {\n\t\tklog.V(2).Infof(\"Deleting IAM role policy %q %q\", roleName, policyName)\n\t\trequest := &iam.DeleteRolePolicyInput{\n\t\t\tRoleName:   aws.String(r.Name),\n\t\t\tPolicyName: aws.String(policyName),\n\t\t}\n\t\t_, err := c.IAM().DeleteRolePolicy(ctx, request)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error deleting IAM role policy %q %q: %v\", roleName, policyName, err)\n\t\t}\n\t}\n\n\t// Detach Managed Policies\n\tfor _, policy := range attachedPolicies {\n\t\tklog.V(2).Infof(\"Detaching IAM role policy %q %v\", roleName, policy)\n\t\trequest := &iam.DetachRolePolicyInput{\n\t\t\tRoleName:  aws.String(r.Name),\n\t\t\tPolicyArn: policy.PolicyArn,\n\t\t}\n\t\t_, err := c.IAM().DetachRolePolicy(ctx, request)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error detaching IAM role policy %q %q: %v\", roleName, *policy.PolicyArn, err)\n\t\t}\n\t}\n\n\t// Delete Role\n\t{","sourceCodeStart":1935,"sourceCodeEnd":1971,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/aws/aws.go#L1935-L1971","documentation":"Fires when iam.DeleteRolePolicy fails to remove a named inline policy from the role during cluster resource teardown — the deletion API call returned an error (permissions, throttling, or unexpected state).","triggerScenarios":"Thrown at pkg/resources/aws/aws.go:1953 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check iam:DeleteRolePolicy permission on the role","Retry; transient throttling or eventual consistency can cause failures","If NoSuchEntity, re-run kops delete to let discovery treat it as 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"}