{"record":{"id":"763e5867b3b975ae","repo":"kubernetes/kops","slug":"error-fetching-dns-hostedzone-by-id-q-v","errorCode":null,"errorMessage":"error fetching DNS HostedZone by id %q: %v","messagePattern":"error fetching DNS HostedZone by id %q: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/dnszone.go","lineNumber":158,"sourceCode":"\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\nfunc (s *DNSZone) CheckChanges(a, e, changes *DNSZone) error {\n\tif fi.ValueOf(e.Name) == \"\" {\n\t\treturn fi.RequiredField(\"Name\")\n\t}\n\treturn nil\n}\n\nfunc (_ *DNSZone) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *DNSZone) error {","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/dnszone.go#L140-L176","documentation":"After ListHostedZonesByName found exactly one matching zone by name, the follow-up Route53 GetHostedZone call for that zone's ID failed. The zone existed moments earlier in the list response, so this usually indicates a transient API failure, permission difference, or the zone being deleted concurrently.","triggerScenarios":"GetHostedZone(zones[0].Id) errors: throttling, AccessDenied on GetHostedZone (though list succeeded), NoSuchHostedZone due to concurrent deletion, network failure between the two calls.","commonSituations":"IAM policy allows list but not get on some zones (resource-level conditions); zone deleted by automation between calls; transient AWS throttling during a large reconcile.","solutions":["Inspect the wrapped %v cause; fix IAM route53:GetHostedZone if AccessDenied","If NoSuchHostedZone, confirm the zone still exists and re-run; clear stale references if it was intentionally deleted","Retry on throttling with backoff","Re-run kops once `aws route53 get-hosted-zone --id <id>` succeeds"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"out, err := r53.ListHostedZonesByName(ctx, &route53.ListHostedZonesByNameInput{DNSName: aws.String(name)})\nif err != nil {\n    return err\n}\nif len(out.HostedZones) == 1 {\n    if _, err := r53.GetHostedZone(ctx, &route53.GetHostedZoneInput{Id: out.HostedZones[0].Id}); err != nil {\n        return fmt.Errorf(\"precheck get after list failed for %s: %w\", aws.ToString(out.HostedZones[0].Id), err)\n    }\n}","typeGuard":"func isNoSuchHostedZone(err error) bool {\n    return awsup.AWSErrorCode(err) == \"NoSuchHostedZone\"\n}","tryCatchPattern":"response, err := cloud.Route53().GetHostedZone(ctx, request)\nif err != nil {\n    if isNoSuchHostedZone(err) {\n        return nil, nil // deleted concurrently; treat as absent and recreate\n    }\n    if isThrottling(err) {\n        return retryWithBackoff(ctx, request)\n    }\n    return nil, fmt.Errorf(\"error fetching DNS HostedZone by id %q: %w\", aws.ToString(request.Id), err)\n}","preventionTips":["Grant both route53:ListHostedZonesByName and route53:GetHostedZone — resource-scoped policies can allow one but not the other","Enable AWS SDK retry mode adaptive for transient throttling","Pause automation that deletes zones while kOps reconciles","Re-run kops after transient AWS failures; state is re-derived on each run"],"tags":["aws","route53","dns","api-error"],"backgroundTag":"aws-api-call-failed","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"}