kubernetes/kops · error
error deleting IAMRolePolicy: %v
Error message
error deleting IAMRolePolicy: %v
What it means
When the rendered inline policy is empty, RenderAWS treats it as a deletion and calls DeleteRolePolicy. If AWS returns an error other than NoSuchEntity (already gone), kops wraps it as 'error deleting IAMRolePolicy' and aborts convergence.
Source
Thrown at upup/pkg/fi/cloudup/awstasks/iamrolepolicy.go:241
return nil
}
if policy == "" {
// A deletion
request := &iam.DeleteRolePolicyInput{}
request.RoleName = e.Role.Name
request.PolicyName = e.Name
klog.V(2).Infof("Deleting role policy %s/%s", aws.ToString(e.Role.Name), aws.ToString(e.Name))
_, err = t.Cloud.IAM().DeleteRolePolicy(ctx, request)
if err != nil {
if awsup.IsIAMNoSuchEntityException(err) {
klog.V(2).Infof("Got NoSuchEntity deleting role policy %s/%s; assuming does not exist", aws.ToString(e.Role.Name), aws.ToString(e.Name))
return nil
}
return fmt.Errorf("error deleting IAMRolePolicy: %v", err)
}
return nil
}
doPut := false
if a == nil {
klog.V(2).Infof("Creating IAMRolePolicy")
doPut = true
} else if changes != nil {
if changes.PolicyDocument != nil {
klog.V(2).Infof("Applying changed role policy to %q:", *e.Name)
actualPolicy, err := a.policyDocumentString()
if err != nil {
return fmt.Errorf("error reading actual policy document: %v", err)
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Read the wrapped AWS error for the specific cause
- Grant iam:DeleteRolePolicy to the kops credentials
- Re-run `kops update cluster` — NoSuchEntity is tolerated, so races usually resolve on retry
- Check whether the role/policy is concurrently managed by CloudFormation or another tool
Example fix
// IAM policy allowing lifecycle operations
{
"Effect": "Allow",
"Action": ["iam:PutRolePolicy","iam:GetRolePolicy","iam:DeleteRolePolicy"],
"Resource": "*"
} Defensive patterns
Strategy: retry
Validate before calling
// pre-check deletion permission
_, err := iamClient.SimulatePrincipalPolicy(ctx, &iam.SimulatePrincipalPolicyInput{
PolicySourceArn: aws.String(kopsRoleArn),
ActionNames: []string{"iam:DeleteRolePolicy"},
}) Try / catch
err := kopsUpdate()
if err != nil && strings.Contains(err.Error(), "error deleting IAMRolePolicy") {
if isThrottling(err) || isConcurrentMutation(err) {
time.Sleep(backoff); retry(kopsUpdate)
} // else inspect wrapped AWS error
} Prevention
- Grant iam:DeleteRolePolicy to kops credentials
- Don't manage the same inline policies with CloudFormation and kops simultaneously
- Serialize kops runs against the same cluster
- Rely on NoSuchEntity tolerance: empty-policy deletions are safe to retry
When it happens
Trigger: DeleteRolePolicy fails with e.g. AccessDenied, LimitExceeded (too many inline policies during cleanup), throttling, or concurrency errors while removing a role's inline policy.
Common situations: Credentials lacking iam:DeleteRolePolicy; another controller/process deleting the same policy concurrently; IAM API throttling; deleted role returning unexpected (non-NoSuchEntity) errors.
Related errors
- IP version is incorrect
- provider ID cannot be empty
- provider ID number cannot be empty
- error listing hosted zones: %w
- arn %q has unrecognized type
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/4307f0dc2fe2527d.
Report an issue: GitHub.