kubernetes/kops · error

error deleting IAM instance profile %q: %v

Error message

error deleting IAM instance profile %q: %v

What it means

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.

Source

Thrown at pkg/resources/aws/aws.go:2063

				InstanceProfileName: profile.InstanceProfileName,
				RoleName:            role.RoleName,
			}
			_, err := c.IAM().RemoveRoleFromInstanceProfile(ctx, request)
			if err != nil {
				return fmt.Errorf("error removing role %q from IAM instance profile %q: %v", aws.ToString(role.RoleName), name, err)
			}
		}
	}

	// Delete the instance profile
	{
		klog.V(2).Infof("Deleting IAM instance profile %q", name)
		request := &iam.DeleteInstanceProfileInput{
			InstanceProfileName: profile.InstanceProfileName,
		}
		_, err := c.IAM().DeleteInstanceProfile(ctx, request)
		if err != nil {
			return fmt.Errorf("error deleting IAM instance profile %q: %v", name, err)
		}
	}

	return nil
}

func ListIAMInstanceProfiles(cloud fi.Cloud, vpcID, clusterName string) ([]*resources.Resource, error) {
	ctx := context.TODO()
	c := cloud.(awsup.AWSCloud)

	var profiles []iamtypes.InstanceProfile
	ownershipTag := "kubernetes.io/cluster/" + clusterName

	request := &iam.ListInstanceProfilesInput{}
	paginator := iam.NewListInstanceProfilesPaginator(c.IAM(), request)
	for paginator.HasMorePages() {
		page, err := paginator.NextPage(ctx)
		if err != nil {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check iam:DeleteInstanceProfile permission
  2. Ensure no EC2 instances still reference the instance profile, then retry
  3. Inspect the wrapped error; NoSuchEntity means it was already deleted
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at pkg/resources/aws/aws.go:2063 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/505e07390c8060bc. Report an issue: GitHub.