{"record":{"id":"966a7f8e186acf74","repo":"kubernetes/kops","slug":"could-not-find-image-for-q","errorCode":null,"errorMessage":"could not find Image for %q","messagePattern":"could not find Image for %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awsup/aws_cloud.go","lineNumber":1765,"sourceCode":"\t\tpage, err := paginator.NextPage(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error listing images: %v\", err)\n\t\t}\n\n\t\tfor _, v := range page.Images {\n\t\t\tif image == nil {\n\t\t\t\timage = &v\n\t\t\t} else {\n\t\t\t\titime, _ := time.Parse(time.RFC3339, *image.CreationDate)\n\t\t\t\tvtime, _ := time.Parse(time.RFC3339, *v.CreationDate)\n\t\t\t\tif vtime.After(itime) {\n\t\t\t\t\timage = &v\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif image == nil {\n\t\treturn nil, fmt.Errorf(\"could not find Image for %q\", name)\n\t}\n\n\tklog.V(4).Infof(\"Resolved image %q\", aws.ToString(image.ImageId))\n\treturn image, nil\n}\n\n// ResolveImageOwnerAlias maps a well-known image owner alias (e.g. \"ubuntu\") to its\n// AWS account ID. Unrecognized owners are returned unchanged.\nfunc ResolveImageOwnerAlias(owner string) string {\n\tswitch owner {\n\tcase \"amazon\", \"amazon.com\":\n\t\treturn WellKnownAccountAmazonLinux2023\n\tcase \"debian\", \"debian11\":\n\t\treturn WellKnownAccountDebian\n\tcase \"flatcar\":\n\t\treturn WellKnownAccountFlatcar\n\tcase \"redhat\", \"redhat.com\":\n\t\treturn WellKnownAccountRedhat","sourceCodeStart":1747,"sourceCodeEnd":1783,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awsup/aws_cloud.go#L1747-L1783","documentation":"Returned by resolveImage (aws_cloud.go:1765) when DescribeImages succeeded (no pages errored) but no image matched the requested name/owner filters. kops keeps the newest candidate among matches, and zero matches yields this error.","triggerScenarios":"The DescribeImages paginator returns pages whose Images slices contain no entry matching the filter — wrong name string, image not shared with this account, image absent in this region, or the owner filter excludes it.","commonSituations":"Pinning an AMI name that the upstream project no longer publishes; using a name published only in a different region; referencing a private AMI not shared with the account; typo in the image name in the cluster spec.","solutions":["List what actually matches: `aws ec2 describe-images --filters Name=name,Values=<name>` in the target region","If empty, the image is not available there — pick a region-correct name or resolve to an explicit AMI ID","For private AMIs, share the image with the account or use the AMI owner's account credentials","Update the pinned image name to a currently published one (upstream names change with releases)"],"exampleFix":"// before\nimage: \"ubuntu-jammy-22.04-amd64-server-20230101\"  # no longer published\n// after\nimage: \"ami-0abcdef1234567890\"  # resolved via aws ec2 describe-images","handlingStrategy":"fallback","validationCode":"// Verify the image resolves before using it in a spec\nout, err := ec2Client.DescribeImages(ctx, &ec2.DescribeImagesInput{\n\tOwners: []string{owner},\n\tFilters: []ec2types.Filter{ec2filter(\"name\", imageName)},\n})\nif err == nil && len(out.Images) == 0 { return fmt.Errorf(\"image %q not found in region %s\", imageName, region) }","typeGuard":null,"tryCatchPattern":"img, err := resolveImage(ctx, ssmClient, ec2Client, name)\nif err != nil {\n\tif strings.Contains(err.Error(), \"could not find Image\") {\n\t\treturn fallbackToDefaultAMI(region) // or abort with a clear message\n\t}\n\treturn err\n}","preventionTips":["Confirm image availability per-region — names differ or may be absent across regions","For private AMIs, verify they are shared with the calling account","Re-check pinned image names after upstream releases; prefer SSM-published parameters or explicit AMI IDs"],"tags":["aws","ec2","ami","not-found"],"backgroundTag":"resource-not-found","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"}