{"record":{"id":"81f95c5e997457f5","repo":"kubernetes/kops","slug":"image-q-must-be-ami-ssm-parameter-name-o","errorCode":null,"errorMessage":"image %q must be ami-*, ssm:<parameter>, <name>, or <owner>/<name>","messagePattern":"image %q must be ami-\\*, ssm:<parameter>, <name>, or <owner>/<name>","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/template_functions_karpenter.go","lineNumber":462,"sourceCode":"\t}\n\n\treturn &karpenterNodePool{\n\t\tAPIVersion: karpenterNodePoolAPIGroup + \"/v1\",\n\t\tKind:       \"NodePool\",\n\t\tMetadata: karpenterObjectMeta{\n\t\t\tName: ig.Name,\n\t\t},\n\t\tSpec: spec,\n\t}, nil\n}\n\nfunc buildKarpenterAMITerms(image string) ([]karpenterAMITerm, error) {\n\timage = strings.TrimSpace(image)\n\tif image == \"\" {\n\t\treturn nil, fmt.Errorf(\"image is required\")\n\t}\n\tif strings.Contains(image, \"://\") {\n\t\treturn nil, fmt.Errorf(\"image %q must be ami-*, ssm:<parameter>, <name>, or <owner>/<name>\", image)\n\t}\n\tif strings.HasPrefix(image, \"ami-\") {\n\t\treturn []karpenterAMITerm{{ID: image}}, nil\n\t}\n\tif strings.HasPrefix(image, \"ssm:\") {\n\t\tparameter := strings.TrimPrefix(image, \"ssm:\")\n\t\tif parameter == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"ssm image parameter is required\")\n\t\t}\n\t\treturn []karpenterAMITerm{{SSMParameter: parameter}}, nil\n\t}\n\n\ttokens := strings.SplitN(image, \"/\", 2)\n\tif len(tokens) == 1 {\n\t\treturn []karpenterAMITerm{{Name: image, Owner: \"self\"}}, nil\n\t}\n\tif tokens[0] == \"\" || tokens[1] == \"\" {\n\t\treturn nil, fmt.Errorf(\"image %q must be ami-*, ssm:<parameter>, <name>, or <owner>/<name>\", image)","sourceCodeStart":444,"sourceCodeEnd":480,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/template_functions_karpenter.go#L444-L480","documentation":"buildKarpenterAMITerms accepts only ami-* ids, ssm: parameters, plain names, or owner/name pairs. An image containing '://' (e.g. a URL or docker-style reference) cannot be mapped to an EC2 AMI term and is rejected with this format error.","triggerScenarios":"Setting the image field to something like docker://... or https://... (any string containing '://') when building the Karpenter EC2NodeClass AMI terms.","commonSituations":"Confusing container image references with AMI selectors; pasting a URL from a browser into the image field; copying ECR image URIs instead of AMI identifiers.","solutions":["Replace the URL with a valid AMI id (ami-*), SSM parameter (ssm:<parameter>), image name, or owner/name alias","Strip any scheme prefix and use the raw AMI identifier","Validate the AMI exists in the target region before re-running update"],"exampleFix":"// before\nimage: https://example.com/my-ami\n// after\nimage: ami-0abcdef1234567890","handlingStrategy":"validation","validationCode":"// reject URL-like image values early\nif strings.Contains(image, \"://\") {\n\treturn fmt.Errorf(\"image must be ami-*, ssm:<parameter>, <name>, or <owner>/<name>; got %q\", image)\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"must be ami-*\") {\n\treturn fmt.Errorf(\"image is not an AMI selector: %w\", err)\n}","preventionTips":["Never paste container image URLs into the AMI image field","Use aws ec2 describe-images to obtain proper AMI ids","Distinguish containerImage references from AMI image selectors in tooling"],"tags":["karpenter","aws","validation","image-format"],"backgroundTag":"invalid-image-format","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"}