kubernetes/kops · error
error creating LaunchTemplateVersion: %v
Error message
error creating LaunchTemplateVersion: %v
What it means
When the launch template already exists, RenderAWS creates a new version via CreateLaunchTemplateVersion instead of a new template. If that API call fails, kOps wraps it as 'error creating LaunchTemplateVersion'. A nil version pointer would also panic here, but the primary trigger is an EC2 API rejection of the new version data.
Source
Thrown at upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go:179
TagSpecifications: []ec2types.TagSpecification{
{
ResourceType: ec2types.ResourceTypeLaunchTemplate,
Tags: tags,
},
},
}
output, err := c.Cloud.EC2().CreateLaunchTemplate(ctx, input)
if err != nil || output.LaunchTemplate == nil {
return fmt.Errorf("error creating LaunchTemplate %q: %v", fi.ValueOf(t.Name), err)
}
e.ID = output.LaunchTemplate.LaunchTemplateId
} else {
input := &ec2.CreateLaunchTemplateVersionInput{
LaunchTemplateName: t.Name,
LaunchTemplateData: data,
}
if version, err := c.Cloud.EC2().CreateLaunchTemplateVersion(ctx, input); err != nil {
return fmt.Errorf("error creating LaunchTemplateVersion: %v", err)
} else {
newDefault := strconv.FormatInt(*version.LaunchTemplateVersion.VersionNumber, 10)
input := &ec2.ModifyLaunchTemplateInput{
DefaultVersion: &newDefault,
LaunchTemplateId: version.LaunchTemplateVersion.LaunchTemplateId,
}
if _, err := c.Cloud.EC2().ModifyLaunchTemplate(ctx, input); err != nil {
return fmt.Errorf("error updating launch template version: %w", err)
}
}
if changes.Tags != nil {
err = c.UpdateTags(fi.ValueOf(a.ID), e.Tags)
if err != nil {
return fmt.Errorf("error updating LaunchTemplate tags: %v", err)
}
}
e.ID = a.ID
View on GitHub (pinned to 4c8573c808)
Solutions
- Read the wrapped AWS error and fix the offending field (commonly UserData size or device mapping).
- Retry the apply if the error was throttling (RequestLimitExceeded).
- Grant ec2:CreateLaunchTemplateVersion in the kops IAM policy.
- If stuck, delete and recreate the launch template task (kops will create a fresh template).
Example fix
// before: version with 70KB userdata rejected // after shrink userdata below 64KB or move payload to an S3-fetched script, then re-run kops update
Defensive patterns
Strategy: retry
Validate before calling
// ensure template exists and userdata size is valid before apply aws ec2 describe-launch-templates --launch-template-ids $LT_ID wc -c userdata.sh # must be < 65536
Try / catch
if strings.Contains(err, "RequestLimitExceeded") { exponential backoff, re-run kops update } else if strings.Contains(err, "InvalidLaunchTemplate") { fix the rejected field per wrapped message and re-apply } Prevention
- Backoff/retry applies around EC2 throttling.
- Keep userdata under 64KB across rollouts.
- Add ec2:CreateLaunchTemplateVersion to the IAM policy.
When it happens
Trigger: RenderAWS on an existing launch template (e.ID set) where CreateLaunchTemplateVersion rejects the LaunchTemplateData - oversized userdata, invalid device mapping/instance type, API throttling, missing IAM permission.
Common situations: Rolling update pushing userdata beyond 64KB; changed instance type not supported in the template's context; EC2 throttling during large cluster updates; IAM policy lacking ec2:CreateLaunchTemplateVersion.
Related errors
- timed out waiting for volume to detach
- error listing AutoScaling LaunchTemplates: %v
- error deleting ec2 LaunchTemplate %q: %v
- error creating LaunchTemplate %q: %v
- error updating launch template version: %w
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/5064e8596a44309f.
Report an issue: GitHub.