kubernetes/kops · error
unable to parse role arn as it is not set
Error message
unable to parse role arn as it is not set
What it means
FindCustomAuthNameFromArn was called with an empty ARN while resolving a custom IAM role/instance-profile name. It is a guard on missing input: the code attempts to extract the resource name after the last '/' of an ARN, and an empty string cannot match.
Source
Thrown at pkg/model/names.go:162
case kops.InstanceGroupRoleAPIServer:
rolename = "apiservers." + b.ClusterName()
case kops.InstanceGroupRoleBastion:
rolename = "bastions." + b.ClusterName()
case kops.InstanceGroupRoleNode:
rolename = "nodes." + b.ClusterName()
default:
klog.Fatalf("unknown InstanceGroup Role: %q", role)
}
return truncate.TruncateString(rolename, truncate.TruncateStringOptions{MaxLength: iam.MaxLengthIAMRoleName, AlwaysAddHash: false})
}
var roleNamRegExp = regexp.MustCompile(`([^/]+$)`)
// FindCustomAuthNameFromArn parses the name of a instance profile from the arn
func FindCustomAuthNameFromArn(arn string) (string, error) {
if arn == "" {
return "", fmt.Errorf("unable to parse role arn as it is not set")
}
rs := roleNamRegExp.FindStringSubmatch(arn)
if len(rs) >= 2 {
return rs[1], nil
}
return "", fmt.Errorf("unable to parse role arn %q", arn)
}
func (b *KopsModelContext) LinkToIAMInstanceProfile(ig *kops.InstanceGroup) (*awstasks.IAMInstanceProfile, error) {
if ig.Spec.IAM != nil && ig.Spec.IAM.Profile != nil {
name, err := FindCustomAuthNameFromArn(fi.ValueOf(ig.Spec.IAM.Profile))
return &awstasks.IAMInstanceProfile{Name: &name}, err
}
name := b.IAMName(ig.Spec.Role)
return &awstasks.IAMInstanceProfile{Name: &name}, nil
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Set the IAM role ARN (e.g. via iam.customProfileName or the relevant role spec field) before invoking cluster build
- Fall back to a kOps-generated role name when no custom ARN is configured
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pkg/model/names.go:162 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/0b9dabd07b0754b5.
Report an issue: GitHub.