kubernetes/kops · error

error finding launch template ID for autoscaling group: %s

Error message

error finding launch template ID for autoscaling group: %s

What it means

Guard error: the ASG's LaunchTemplateSpecification exists but its LaunchTemplateId field is empty, so the launch template version cannot be resolved. The ASG named by %s carries a malformed launch template reference.

Source

Thrown at upup/pkg/fi/cloudup/awsup/aws_cloud.go:940

func findAutoscalingGroupLaunchConfiguration(ctx context.Context, c AWSCloud, g *autoscalingtypes.AutoScalingGroup) (string, error) {
	name := aws.ToString(g.LaunchConfigurationName)
	if name != "" {
		return name, nil
	}

	// @check the launch template then
	var launchTemplate *autoscalingtypes.LaunchTemplateSpecification
	if g.LaunchTemplate != nil {
		launchTemplate = g.LaunchTemplate
	} else if g.MixedInstancesPolicy != nil && g.MixedInstancesPolicy.LaunchTemplate != nil && g.MixedInstancesPolicy.LaunchTemplate.LaunchTemplateSpecification != nil {
		launchTemplate = g.MixedInstancesPolicy.LaunchTemplate.LaunchTemplateSpecification
	} else {
		return "", fmt.Errorf("error finding launch template or configuration for autoscaling group: %s", aws.ToString(g.AutoScalingGroupName))
	}

	id := aws.ToString(launchTemplate.LaunchTemplateId)
	if id == "" {
		return "", fmt.Errorf("error finding launch template ID for autoscaling group: %s", aws.ToString(g.AutoScalingGroupName))
	}

	version := aws.ToString(launchTemplate.Version)
	// Correctly Handle Default and Latest Versions
	klog.V(4).Infof("Launch Template Version Specified By ASG: %v", version)
	if version == "" || version == "$Default" || version == "$Latest" {
		input := &ec2.DescribeLaunchTemplatesInput{
			LaunchTemplateIds: []string{id},
		}
		output, err := c.EC2().DescribeLaunchTemplates(ctx, input)
		if err != nil {
			return "", fmt.Errorf("error describing launch templates: %q", err)
		}
		if len(output.LaunchTemplates) == 0 {
			return "", fmt.Errorf("error finding launch template by ID: %q", id)
		}
		launchTemplate := output.LaunchTemplates[0]
		if version == "$Latest" {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Inspect the named ASG's launch template specification in AWS and fix or reattach the launch template so it carries an ID
  2. Recreate the ASG via kops rolling-update to restore a well-formed launch template reference
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/awsup/aws_cloud.go:940 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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