{"record":{"id":"a4078ccc7e045be9","repo":"kubernetes/kops","slug":"error-updating-launch-template-version-w","errorCode":null,"errorMessage":"error updating launch template version: %w","messagePattern":"error updating launch template version: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go","lineNumber":187,"sourceCode":"\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\n\t}\n\n\treturn nil\n}\n\n// Find is responsible for finding the launch template for us\nfunc (t *LaunchTemplate) Find(c *fi.CloudupContext) (*LaunchTemplate, error) {\n\tcloud := awsup.GetCloud(c)","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go#L169-L205","documentation":"After successfully creating a new launch template version, RenderAWS calls ModifyLaunchTemplate to set that version as the default. If ModifyLaunchTemplate fails, the error is wrapped as 'error updating launch template version'. The cluster ends up with a new version created but not made default, so instances won't pick up the change.","triggerScenarios":"RenderAWS, existing template path: CreateLaunchTemplateVersion succeeds, then EC2 ModifyLaunchTemplate with DefaultVersion=<new number> errors - throttling, template deleted concurrently, IAM permission missing, or transient AWS fault.","commonSituations":"Concurrent kops applies racing on the same template; ec2:ModifyLaunchTemplate missing from IAM policy; throttling during large rolling updates; template removed by an external tool between the two calls.","solutions":["Re-run kops update - the next apply will create/update the default version again.","Ensure IAM policy includes ec2:ModifyLaunchTemplate.","Avoid concurrent applies against the same cluster (CI race).","Retry if the wrapped error was throttling or a transient AWS error."],"exampleFix":"// before: two CI jobs running kops update concurrently\n// after\nserialize applies (single pipeline) or acquire a lock before kops update","handlingStrategy":"retry","validationCode":"// ensure the template still exists right before apply\naws ec2 describe-launch-templates --launch-template-ids $LT_ID 2>/dev/null || echo \"template missing\"","typeGuard":null,"tryCatchPattern":"if strings.Contains(err, \"error updating launch template version\") { re-run kops update once after backoff; if persistent, check ec2:ModifyLaunchTemplate IAM permission }","preventionTips":["Serialize kops applies - no concurrent updates to one cluster.","Include ec2:ModifyLaunchTemplate in the kops IAM policy.","Avoid external tooling deleting launch templates kOps manages.","Retry transient AWS errors with backoff."],"tags":["aws","ec2","launch-template","modify-launch-template"],"backgroundTag":"modify-launch-template-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"}