{"record":{"id":"74b7d7149031713b","repo":"kubernetes/kops","slug":"found-multiple-hosted-zones-matching-cluster-q-p","errorCode":null,"errorMessage":"Found multiple hosted zones matching cluster %q; please specify the ID of the zone to use","messagePattern":"Found multiple hosted zones matching cluster %q; please specify the ID of the zone to use","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/utils.go","lineNumber":310,"sourceCode":"\t\tmaxLengthZones = append(maxLengthZones, z)\n\t}\n\n\tif len(maxLengthZones) == 0 {\n\t\t// We make this an error because you have to set up DNS delegation anyway\n\t\ttokens := strings.Split(clusterDNSName, \".\")\n\t\tsuffix := strings.Join(tokens[len(tokens)-2:], \".\")\n\t\t// klog.Warningf(\"No matching hosted zones found; will created %q\", suffix)\n\t\t// return suffix, nil\n\t\treturn \"\", fmt.Errorf(\"No matching hosted zones found for %q; please create one (e.g. %q) first\", clusterDNSName, suffix)\n\t}\n\n\tif len(maxLengthZones) == 1 {\n\t\tid := maxLengthZones[0].ID()\n\t\tid = strings.TrimPrefix(id, \"/hostedzone/\")\n\t\treturn id, nil\n\t}\n\n\treturn \"\", fmt.Errorf(\"Found multiple hosted zones matching cluster %q; please specify the ID of the zone to use\", clusterDNSName)\n}\n","sourceCodeStart":292,"sourceCodeEnd":312,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/utils.go#L292-L312","documentation":"When more than one hosted zone is a suffix match for the cluster DNS name (same maximal length), kops cannot decide which zone to use for records and fails, asking the operator to specify the zone ID explicitly (via the cluster spec's DNSZone / config).","triggerScenarios":"FindDNSHostedZone encounters two or more hosted zones with identical names covering the cluster domain — e.g. duplicate public and private zones, or a zone accidentally created twice — during create/update cluster.","commonSituations":"Route53 account contains both a public and private zone for the same domain name; a previous abandoned `create-hosted-zone` left a duplicate; cross-account migration left stale zones; delegation split across example.com and example.com (duplicate) zones.","solutions":["Set the zone ID explicitly in the cluster spec: `kops edit cluster` then set `spec.dnsZone: Z1DXXXXXXXXXX` (or `--dns-zone` flag at create time).","Delete the duplicate/stale hosted zone in the DNS console (`aws route53 delete-hosted-zone --id ...`).","If public vs private is the cause, keep the intended one for the cluster or pin it via dnsZone."],"exampleFix":"# before\nspec: {}\n# after\nspec:\n  dnsZone: Z1DXXXXXXXXXX","handlingStrategy":"validation","validationCode":"zones := listMatchingZones(clusterDNSName)\nif len(zones) > 1 { return fmt.Errorf(\"set spec.dnsZone explicitly\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pin spec.dnsZone / --dns-zone when multiple zones share a name.","Delete duplicate or abandoned hosted zones.","Distinguish public vs private zones and pick one explicitly."],"tags":["dns","route53","hosted-zone","ambiguity"],"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"}