kubernetes/kops · error
expected a aws.Cloud provider
Error message
expected a aws.Cloud provider
What it means
Returned immediately after the launch template specification is resolved: LaunchTemplateId was present as a field but empty (aws.ToString yielded ""). kOps needs a concrete ID to describe/compare the template during rolling updates.
Source
Thrown at pkg/resources/aws/aws.go:1438
for _, eip := range response.Addresses {
eipTracker := buildElasticIPResource(eip, !ownedNatGatewayIds.Has(natGatewayId), clusterName)
resourceTrackers = append(resourceTrackers, eipTracker)
}
}
}
}
}
return resourceTrackers, nil
}
// DeleteAutoScalingGroupLaunchTemplate deletes
func DeleteAutoScalingGroupLaunchTemplate(cloud fi.Cloud, r *resources.Resource) error {
ctx := context.TODO()
c, ok := cloud.(awsup.AWSCloud)
if !ok {
return errors.New("expected a aws.Cloud provider")
}
klog.V(2).Infof("Deleting EC2 LaunchTemplate %q", r.ID)
if _, err := c.EC2().DeleteLaunchTemplate(ctx, &ec2.DeleteLaunchTemplateInput{
LaunchTemplateId: new(r.ID),
}); err != nil {
return fmt.Errorf("error deleting ec2 LaunchTemplate %q: %v", r.ID, err)
}
return nil
}
func DeleteELB(cloud fi.Cloud, r *resources.Resource) error {
ctx := context.TODO()
c := cloud.(awsup.AWSCloud)
id := r.ID
View on GitHub (pinned to 4c8573c808)
Solutions
- Inspect the ASG's MixedInstancesPolicy with `aws autoscaling describe-auto-scaling-groups` and fix the launch template reference
- Re-create the ASG through `kops update cluster` so a valid launch template is attached
- Re-run the operation if it was a transient mid-update race
Example fix
// before
id := aws.ToString(launchTemplate.LaunchTemplateId)
if id == "" {
return "", fmt.Errorf("error finding launch template ID for autoscaling group: %s", aws.ToString(g.AutoScalingGroupName))
}
// after
if launchTemplate.LaunchTemplateId == nil || aws.ToString(launchTemplate.LaunchTemplateId) == "" {
return "", fmt.Errorf("ASG %s has a launch template spec with empty LaunchTemplateId", aws.ToString(g.AutoScalingGroupName))
}
id := aws.ToString(launchTemplate.LaunchTemplateId) Defensive patterns
Strategy: type-guard
Validate before calling
if g.LaunchTemplate != nil && aws.ToString(g.LaunchTemplate.LaunchTemplateId) == "" {
return fmt.Errorf("ASG %q has empty LaunchTemplateId", aws.ToString(g.AutoScalingGroupName))
} Type guard
func hasLaunchTemplateID(g *autoscalingtypes.AutoScalingGroup) bool {
lt := g.LaunchTemplate
if lt == nil && g.MixedInstancesPolicy != nil && g.MixedInstancesPolicy.LaunchTemplate != nil { lt = g.MixedInstancesPolicy.LaunchTemplate.LaunchTemplateSpecification }
return lt != nil && aws.ToString(lt.LaunchTemplateId) != ""
} Try / catch
err := op(ctx)
if strings.Contains(err.Error(), "error finding launch template ID") {
// re-describe the ASG; a mid-update race often resolves on a fresh read
time.Sleep(backoff); retry()
} Prevention
- Do not mutate ASG launch templates during rolling updates
- Reject ASGs with incomplete MixedInstancesPolicy at creation time
- Serialize ASG updates with kops/IaC tooling
- Re-describe the ASG before acting on cached group data
When it happens
Trigger: The ASG's LaunchTemplateSpecification exists but has an empty/nil LaunchTemplateId — typically a malformed or partially populated MixedInstancesPolicy returned by the API, or an ASG created/updated concurrently.
Common situations: Externally managed ASGs with broken mixed-instances policy; race during ASG update where the template spec is mid-mutation; custom tooling writing incomplete ASG definitions.
Related errors
- DIGITALOCEAN_ACCESS_TOKEN is required
- errShutdown
- could not find one of launch template or mixed instances pol
- DIGITALOCEAN_ACCESS_TOKEN is required
- the image for the hook exec action not set
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/659f3e364f9e93a6.
Report an issue: GitHub.