{"record":{"id":"72692988e38dd16a","repo":"kubernetes/kops","slug":"error-adding-tags-to-resource-q-v","errorCode":null,"errorMessage":"error adding tags to resource %q: %v","messagePattern":"error adding tags to resource %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awsup/aws_cloud.go","lineNumber":1407,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"unexpected error fetching tags for resource: %v\", err)\n\t}\n\n\tmissing := map[string]string{}\n\tfor k, v := range expected {\n\t\tactualValue, found := actual[k]\n\t\tif found && actualValue == v {\n\t\t\tcontinue\n\t\t}\n\t\tmissing[k] = v\n\t}\n\n\tif len(missing) != 0 {\n\t\tklog.V(4).Infof(\"adding tags to %q: %v\", id, missing)\n\n\t\terr := c.CreateTags(id, missing)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error adding tags to resource %q: %v\", id, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (c *awsCloudImplementation) RemoveELBV2Tags(ResourceArn string, tags map[string]string) error {\n\treturn removeELBV2Tags(c, ResourceArn, tags)\n}\n\nfunc removeELBV2Tags(c AWSCloud, ResourceArn string, tags map[string]string) error {\n\tctx := context.TODO()\n\tif len(tags) == 0 {\n\t\treturn nil\n\t}\n\n\telbTagKeysOnly := []string{}\n\tfor k := range tags {","sourceCodeStart":1389,"sourceCodeEnd":1425,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awsup/aws_cloud.go#L1389-L1425","documentation":"addAWSTags computed the set of missing tags but the subsequent CreateTags call failed, so the tags listed in the preceding V(4) log line were not applied to resource %q.","triggerScenarios":"CreateTags called with tags that violate AWS constraints (invalid characters, >50 tags, empty key, key/value too long), missing ec2:CreateTags permission, or throttling.","commonSituations":"Cluster name or tag values containing characters AWS rejects; very large clusters exceeding the 50-tag limit per resource; IAM role without tag permissions; TagLimitExceeded on legacy resources.","solutions":["Check the wrapped AWS error code and fix the offending tag key/value (allowed chars, length limits, max 50 tags).","Ensure the IAM policy grants ec2:CreateTags.","Reduce number of custom tags or remove unused ones.","Retry if the error was throttling (Transient/ThrottlingException)."],"exampleFix":"// before: invalid characters in tag value\nclusterName: \"my_cluster@prod\" // rejected by CreateTags\n// after: use DNS/AWS-safe characters\nclusterName: \"my-cluster-prod\"","handlingStrategy":"validation","validationCode":"// Pre-validate tags against AWS constraints before CreateTags\nfunc validTags(tags map[string]string) bool {\n    if len(tags) > 50 { return false }\n    for k, v := range tags {\n        if k == \"\" || len(k) > 128 || len(v) > 256 { return false }\n    }\n    return true\n}","typeGuard":null,"tryCatchPattern":"err := c.CreateTags(ctx, id, missing)\nif err != nil {\n    var ae smithy.APIError\n    if errors.As(err, &ae) && ae.ErrorCode() == \"TagLimitExceeded\" {\n        return fmt.Errorf(\"resource %s at tag limit; remove unused tags\", id)\n    }\n    return fmt.Errorf(\"adding tags to %s: %w\", id, err)\n}","preventionTips":["Keep custom tags well below the 50-tag limit","Use AWS-safe characters ([a-zA-Z0-9_-./+]) in keys and values","Grant ec2:CreateTags to the operator role","Count existing tags before adding new ones"],"tags":["aws","ec2","tags","create-tags"],"backgroundTag":"aws-api-error","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"}