{"record":{"id":"0508f173d69ebb06","repo":"kubernetes/kops","slug":"error-listing-autoscaling-launchtemplates-v-0508f1","errorCode":null,"errorMessage":"error listing AutoScaling LaunchTemplates: %v","messagePattern":"error listing AutoScaling LaunchTemplates: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go","lineNumber":377,"sourceCode":"\tctx := c.Context()\n\n\tcloud := awsup.GetCloud(c)\n\n\tinput := &ec2.DescribeLaunchTemplatesInput{\n\t\tFilters: []ec2types.Filter{\n\t\t\t{\n\t\t\t\tName:   aws.String(\"tag:Name\"),\n\t\t\t\tValues: []string{fi.ValueOf(t.Name)},\n\t\t\t},\n\t\t},\n\t}\n\n\tvar list []ec2types.LaunchTemplate\n\tpaginator := ec2.NewDescribeLaunchTemplatesPaginator(cloud.EC2(), input)\n\tfor paginator.HasMorePages() {\n\t\tpage, err := paginator.NextPage(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error listing AutoScaling LaunchTemplates: %v\", err)\n\t\t}\n\t\tlist = append(list, page.LaunchTemplates...)\n\t}\n\n\treturn list, nil\n}\n\n// findLatestLaunchTemplateVersion returns the latest template version\nfunc (t *LaunchTemplate) findLatestLaunchTemplateVersion(c *fi.CloudupContext) (*ec2types.LaunchTemplateVersion, error) {\n\tctx := c.Context()\n\n\tcloud := awsup.GetCloud(c)\n\n\tinput := &ec2.DescribeLaunchTemplateVersionsInput{\n\t\tLaunchTemplateName: t.Name,\n\t\tVersions:           []string{(\"$Latest\")},\n\t}\n","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go#L359-L395","documentation":"findAllLaunchTemplates pages through ec2:DescribeLaunchTemplates to collect all kOps-managed launch templates, and wraps any paginator error in this message. It is thrown from FindDeletions when the AWS API call itself fails, so the list of orphaned launch templates cannot be computed.","triggerScenarios":"paginator.NextPage returns an error: API throttling, UnauthorizedOperation/AccessDenied on ec2:DescribeLaunchTemplates, invalid filter values, network failure, or region misconfiguration.","commonSituations":"IAM policy lacking ec2:DescribeLaunchTemplates, heavy API load causing rate limiting, wrong AWS_PROFILE/region, transient network errors in CI.","solutions":["Check the wrapped %v error for the exact AWS error code","Grant ec2:DescribeLaunchTemplates to the kOps IAM role/policy","Retry the operation; throttling errors are transient","Verify AWS credentials and region configuration (aws sts get-caller-identity)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-check IAM\n_, err := cloud.EC2().DescribeLaunchTemplates(ctx, &ec2types.DescribeLaunchTemplatesInput{MaxResults: aws.Int32(1)})\nif err != nil { /* fail fast: describe permission missing */ }","typeGuard":null,"tryCatchPattern":"page, err := paginator.NextPage(ctx)\nif err != nil {\n  var re *awshttp.ResponseError\n  if errors.As(err, &re) && strings.Contains(re.Error(), \"Throttling\") {\n    time.Sleep(backoff); continue\n  }\n  return nil, fmt.Errorf(\"error listing AutoScaling LaunchTemplates: %w\", err)\n}","preventionTips":["Grant ec2:DescribeLaunchTemplates to the kOps role","Add exponential backoff for paginated calls","Verify region/profile before running kops"],"tags":["aws","ec2","launch-template","api-pagination"],"backgroundTag":"aws-api-access-denied","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}