{"record":{"id":"ea74c31edbfcc0ef","repo":"kubernetes/kops","slug":"found-multiple-hosted-zones-matched-name-q","errorCode":null,"errorMessage":"found multiple hosted zones matched name %q","messagePattern":"found multiple hosted zones matched name %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/dnszone.go","lineNumber":150,"sourceCode":"\t\tDNSName: aws.String(findName),\n\t}\n\n\tresponse, err := cloud.Route53().ListHostedZonesByName(ctx, request)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing DNS HostedZones: %v\", err)\n\t}\n\n\tvar zones []route53types.HostedZone\n\tfor _, zone := range response.HostedZones {\n\t\tif aws.ToString(zone.Name) == findName && zone.Config.PrivateZone == fi.ValueOf(e.Private) {\n\t\t\tzones = append(zones, zone)\n\t\t}\n\t}\n\n\tif len(zones) == 0 {\n\t\treturn nil, nil\n\t} else if len(zones) != 1 {\n\t\treturn nil, fmt.Errorf(\"found multiple hosted zones matched name %q\", findName)\n\t} else {\n\t\trequest := &route53.GetHostedZoneInput{\n\t\t\tId: zones[0].Id,\n\t\t}\n\n\t\tresponse, err := cloud.Route53().GetHostedZone(ctx, request)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error fetching DNS HostedZone by id %q: %v\", *request.Id, err)\n\t\t}\n\n\t\treturn response, nil\n\t}\n}\n\nfunc (e *DNSZone) Run(c *fi.CloudupContext) error {\n\treturn fi.CloudupDefaultDeltaRunMethod(e, c)\n}\n","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/dnszone.go#L132-L168","documentation":"findExisting matched more than one Route53 hosted zone with the same DNS name and the same private/public setting, so kOps cannot determine which zone the DNSZone task refers to and aborts instead of guessing. Route53 permits duplicate zone names across accounts/within limits, so ambiguity must be resolved by the user.","triggerScenarios":"Two or more hosted zones in the account share the exact DNSName (with trailing dot) of e.DNSName and the same PrivateZone value as e.Private, while the task spec carries no ZoneID.","commonSituations":"A previous failed kOps run created a zone, then the zone was recreated manually or by another run; importing the same cluster twice into one account; leftover zones from destroyed clusters that kept the domain.","solutions":["Set the zone's ID explicitly in the cluster spec (spec.dnsZone / ZoneID) so findExisting uses GetHostedZone by ID and skips the ambiguous name search","Delete or rename the duplicate hosted zone (`aws route53 list-hosted-zones-by-name --dns-name example.com.` then delete the unwanted one)","Differentiate by making one zone private and the other public if that matches intent"],"exampleFix":"// cluster.yaml — before\ncluster.spec.dnsZone: example.com\n// after\ncluster.spec.dnsZone: Z123456ABCDEFG  # explicit hosted zone id","handlingStrategy":"validation","validationCode":"func assertUniqueZone(ctx context.Context, r53 *route53.Client, dnsName string, private bool) error {\n    name := strings.TrimSuffix(dnsName, \".\") + \".\"\n    out, err := r53.ListHostedZonesByName(ctx, &route53.ListHostedZonesByNameInput{DNSName: aws.String(name)})\n    if err != nil {\n        return err\n    }\n    n := 0\n    for _, z := range out.HostedZones {\n        if aws.ToString(z.Name) == name && z.Config.PrivateZone == private {\n            n++\n        }\n    }\n    if n > 1 {\n        return fmt.Errorf(\"%d hosted zones named %q (private=%v); set an explicit zone ID\", n, name, private)\n    }\n    return nil\n}","typeGuard":"func uniqueZoneID(zones []route53types.HostedZone, name string, private bool) (string, bool) {\n    var ids []string\n    for _, z := range zones {\n        if aws.ToString(z.Name) == name && z.Config.PrivateZone == private {\n            ids = append(ids, aws.ToString(z.Id))\n        }\n    }\n    if len(ids) == 1 {\n        return ids[0], true\n    }\n    return \"\", false\n}","tryCatchPattern":null,"preventionTips":["Always pin the cluster's DNS zone by ID (cluster.spec.dnsZone = hosted zone ID) instead of by name","Before creating clusters, check for existing zones: `aws route53 list-hosted-zones-by-name --dns-name example.com.`","Clean up leftover hosted zones from destroyed/failed clusters","Never create duplicate zones for the same domain manually while kOps manages it"],"tags":["aws","route53","dns","ambiguity","configuration"],"backgroundTag":"ambiguous-hosted-zone","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"}