{"record":{"id":"5064e8596a44309f","repo":"kubernetes/kops","slug":"error-creating-launchtemplateversion-v","errorCode":null,"errorMessage":"error creating LaunchTemplateVersion: %v","messagePattern":"error creating LaunchTemplateVersion: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go","lineNumber":179,"sourceCode":"\t\t\tTagSpecifications: []ec2types.TagSpecification{\n\t\t\t\t{\n\t\t\t\t\tResourceType: ec2types.ResourceTypeLaunchTemplate,\n\t\t\t\t\tTags:         tags,\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t\toutput, err := c.Cloud.EC2().CreateLaunchTemplate(ctx, input)\n\t\tif err != nil || output.LaunchTemplate == nil {\n\t\t\treturn fmt.Errorf(\"error creating LaunchTemplate %q: %v\", fi.ValueOf(t.Name), err)\n\t\t}\n\t\te.ID = output.LaunchTemplate.LaunchTemplateId\n\t} else {\n\t\tinput := &ec2.CreateLaunchTemplateVersionInput{\n\t\t\tLaunchTemplateName: t.Name,\n\t\t\tLaunchTemplateData: data,\n\t\t}\n\t\tif version, err := c.Cloud.EC2().CreateLaunchTemplateVersion(ctx, input); err != nil {\n\t\t\treturn fmt.Errorf(\"error creating LaunchTemplateVersion: %v\", err)\n\t\t} else {\n\t\t\tnewDefault := strconv.FormatInt(*version.LaunchTemplateVersion.VersionNumber, 10)\n\t\t\tinput := &ec2.ModifyLaunchTemplateInput{\n\t\t\t\tDefaultVersion:   &newDefault,\n\t\t\t\tLaunchTemplateId: version.LaunchTemplateVersion.LaunchTemplateId,\n\t\t\t}\n\t\t\tif _, err := c.Cloud.EC2().ModifyLaunchTemplate(ctx, input); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error updating launch template version: %w\", err)\n\t\t\t}\n\t\t}\n\t\tif changes.Tags != nil {\n\t\t\terr = c.UpdateTags(fi.ValueOf(a.ID), e.Tags)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error updating LaunchTemplate tags: %v\", err)\n\t\t\t}\n\t\t}\n\t\te.ID = a.ID\n","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go#L161-L197","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before: version with 70KB userdata rejected\n// after\nshrink userdata below 64KB or move payload to an S3-fetched script, then re-run kops update","handlingStrategy":"retry","validationCode":"// ensure template exists and userdata size is valid before apply\naws ec2 describe-launch-templates --launch-template-ids $LT_ID\nwc -c userdata.sh  # must be < 65536","typeGuard":null,"tryCatchPattern":"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 }","preventionTips":["Backoff/retry applies around EC2 throttling.","Keep userdata under 64KB across rollouts.","Add ec2:CreateLaunchTemplateVersion to the IAM policy."],"tags":["aws","ec2","launch-template","version"],"backgroundTag":"launch-template-version-failed","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"}