{"record":{"id":"ecd84dbac90a27ec","repo":"kubernetes/kops","slug":"error-updating-launchtemplate-tags-v","errorCode":null,"errorMessage":"error updating LaunchTemplate tags: %v","messagePattern":"error updating LaunchTemplate tags: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go","lineNumber":193,"sourceCode":"\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)\n\n\t// @step: get the latest launch template version\n\tlt, err := t.findLatestLaunchTemplateVersion(c)\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go#L175-L211","documentation":"This error wraps a failure from c.UpdateTags() while applying tag changes to an existing EC2 Launch Template during RenderAWS. It is thrown when the task diff detects a Tags change and the CreateTags API call on the launch template fails. The launch template itself exists; only the tag mutation failed, so the error is a partial-update failure for the resource.","triggerScenarios":"RenderAWS finds changes.Tags != nil and calls UpdateTags on the launch template ID; the underlying ec2.CreateTags call fails due to invalid tag keys/values, too many tags (max 50), invalid characters, throttling, or the template being deleted concurrently.","commonSituations":"Cluster spec tags containing characters EC2 rejects (e.g. 'aws:' prefixed reserved keys on some resources, empty keys), tag limits exceeded after adding many cluster tags, AWS API throttling on large clusters, IAM policy missing ec2:CreateTags permission.","solutions":["Check the wrapped %v message for the exact EC2 error code (InvalidParameterValue, Throttling, UnauthorizedOperation)","Verify tag keys/values meet EC2 constraints (1-128 chars key, 1-256 chars value, allowed characters, no 'aws:' prefix)","Ensure the IAM role of the controller has ec2:CreateTags permission on launch templates","Retry on throttling; reduce concurrent API calls or add backoff","Confirm the launch template still exists before updating (it may have been deleted out-of-band)"],"exampleFix":"// before\nc.tags[\"kops.k8s.io/cluster\"] = \"\" // empty tag value causing InvalidParameterValue\n// after\nc.tags[\"kops.k8s.io/cluster\"] = clusterName // valid non-empty value","handlingStrategy":"validation","validationCode":"for k, v := range desiredTags {\n  if k == \"\" || len(k) > 128 || len(v) > 256 { return fmt.Errorf(\"invalid tag %q\", k) }\n  if strings.HasPrefix(strings.ToLower(k), \"aws:\") { return fmt.Errorf(\"reserved tag key %q\", k) }\n}\nif len(desiredTags) > 50 { return errors.New(\"too many tags (max 50)\") }","typeGuard":null,"tryCatchPattern":"err := c.UpdateTags(id, tags)\nif err != nil {\n  var awsErr smithy.APIError\n  if errors.As(err, &awsErr) && awsErr.ErrorCode() == \"ThrottlingException\" {\n    // back off and retry\n  }\n  return fmt.Errorf(\"error updating LaunchTemplate tags: %w\", err)\n}","preventionTips":["Validate tag key/value length and characters before apply","Avoid reserved 'aws:' key prefixes","Keep tag count under 50 per resource","Ensure ec2:CreateTags in the IAM policy","Add retry with backoff for throttling"],"tags":["aws","ec2","launch-template","tags"],"backgroundTag":"ec2-tag-update-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"}