kubernetes/kops · error

error updating launch template version: %w

Error message

error updating launch template version: %w

What it means

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.

Source

Thrown at upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go:187

		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

	}

	return nil
}

// Find is responsible for finding the launch template for us
func (t *LaunchTemplate) Find(c *fi.CloudupContext) (*LaunchTemplate, error) {
	cloud := awsup.GetCloud(c)

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Re-run kops update - the next apply will create/update the default version again.
  2. Ensure IAM policy includes ec2:ModifyLaunchTemplate.
  3. Avoid concurrent applies against the same cluster (CI race).
  4. Retry if the wrapped error was throttling or a transient AWS error.

Example fix

// before: two CI jobs running kops update concurrently
// after
serialize applies (single pipeline) or acquire a lock before kops update
Defensive patterns

Strategy: retry

Validate before calling

// ensure the template still exists right before apply
aws ec2 describe-launch-templates --launch-template-ids $LT_ID 2>/dev/null || echo "template missing"

Try / catch

if strings.Contains(err, "error updating launch template version") { re-run kops update once after backoff; if persistent, check ec2:ModifyLaunchTemplate IAM permission }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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