{"record":{"id":"d98e48665b1eaca2","repo":"kubernetes/kops","slug":"found-multiple-dns-zones-matching-q","errorCode":null,"errorMessage":"found multiple DNS Zones matching %q","messagePattern":"found multiple DNS Zones matching %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/dns.go","lineNumber":84,"sourceCode":"\tfindName := strings.TrimSuffix(cluster.Spec.DNSZone, \".\")\n\tfor _, zone := range zones {\n\t\tid := zone.ID()\n\t\tname := strings.TrimSuffix(zone.Name(), \".\")\n\t\tif id == cluster.Spec.DNSZone || name == findName {\n\t\t\tmatches = append(matches, zone)\n\t\t}\n\t}\n\tif len(matches) == 0 {\n\t\treturn nil, fmt.Errorf(\"cannot find DNS Zone %q.  Please pre-create the zone and set up NS records so that it resolves\", cluster.Spec.DNSZone)\n\t}\n\n\tif len(matches) > 1 {\n\t\tklog.Infof(\"Found multiple DNS Zones matching %q, please set the cluster's spec.dnsZone to the desired Zone ID:\", cluster.Spec.DNSZone)\n\t\tfor _, zone := range zones {\n\t\t\tid := zone.ID()\n\t\t\tklog.Infof(\"\\t%s\", id)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"found multiple DNS Zones matching %q\", cluster.Spec.DNSZone)\n\t}\n\n\tzone := matches[0]\n\treturn zone, nil\n}\n\nfunc validateDNS(cluster *kops.Cluster, cloud fi.Cloud) error {\n\tif !cluster.PublishesDNSRecords() || cluster.UsesPrivateDNS() {\n\t\tklog.V(2).Infof(\"Skipping DNS validation for non-public DNS\")\n\t\treturn nil\n\t}\n\n\tzone, err := findZone(cluster, cloud)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif zone == nil {\n\t\treturn nil","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/dns.go#L66-L102","documentation":"If more than one zone in the provider matches cluster.Spec.DNSZone (by ID or name), findZone refuses to guess and returns 'found multiple DNS Zones matching %q', logging the candidate zone IDs. kOps requires an unambiguous zone reference to place cluster DNS records.","triggerScenarios":"validateDNS/precreateDNS where DNSZone string matches both a zone ID and another zone's name, or matches multiple zones — e.g. one zone name given but both a public and private hosted zone with the same domain exist.","commonSituations":"Duplicate hosted zones with the same domain (public + private) in Route53; a stale and a recreated zone both present; specifying a name that also equals another zone's ID string.","solutions":["Set spec.dnsZone to the specific zone ID (e.g. /hostedzone/Z123456ABCDEFG) instead of the zone name to disambiguate","Delete or consolidate the duplicate/stale DNS zone in the provider console","Re-run after ensuring only one matching zone exists"],"exampleFix":"// before\nspec:\n  dnsZone: \"example.com\"   # matches public and private zones\n// after\nspec:\n  dnsZone: \"/hostedzone/Z1D633PJN98FT9\"   # exact zone ID","handlingStrategy":"validation","validationCode":"// Use the unambiguous zone ID form\nif !strings.HasPrefix(cluster.Spec.DNSZone, \"/hostedzone/\") && zoneNameIsAmbiguous(cluster.Spec.DNSZone) {\n    return errors.New(\"multiple zones match name; set dnsZone to the zone ID\")\n}","typeGuard":null,"tryCatchPattern":"zone, err := findZone(cluster, cloud)\nif err != nil {\n    if strings.Contains(err.Error(), \"found multiple DNS Zones\") {\n        return fmt.Errorf(\"set spec.dnsZone to one of the logged zone IDs\")\n    }\n    return err\n}","preventionTips":["Reference zones by ID when public and private zones share a name","Remove stale/duplicate hosted zones","Standardize one hosted zone per domain per account"],"tags":["dns","ambiguity","zone-lookup","route53"],"backgroundTag":"dns-zone-ambiguous","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"}