1

I'm using Google's CloudDNS API to batch upload a bunch of domains to Google Cloud. I want to be able to override the default nameservers that Google randomly assigns for example

  • ns-cloud-e1.google.com
  • ns-cloud-e2.google.com
  • ns-cloud-e3.google.com
  • ns-cloud-e4.google.com

to

  • n1.domain.com
  • n2.domain.com
  • n3.domain.com

I've noticed that Google's CloudDNS API's documentation references the following

nameServerSet (string) -

Optionally specifies the NameServerSet for this ManagedZone. A NameServerSet is a set of DNS name servers that all host the same ManagedZones. Most users will leave this field unset.

Though when trying to use this property via the CloudDNS, I receive a response from the API saying that the data provided through data is invalid. I passed through in the format of "n1.domain.com.,n2.domain.com.,n3.domain.com.". I've also tried passing through an array of nameservers and a RecordResourceSet class from the Google PHP package, with no avail.

Is this the correct format I should be following or is it not possible to pre-define the nameservers when the managed zone is created and instead have to do this after the zone is created?

Code example below, $cloud_dns->service is an instance of Google_Service_Dns

$cloud_dns->service->managedZones
    ->create(
         'blah',
         new Google_Service_Dns_ManagedZone([
             'dnsName'       => $dns_name_formatted,
             'name'          => 'app-' . $domain_name,
             'description'   => 'Batch Uploaded Domain',
             'nameServerSet' => 'n1.domain.com.,n2.domain.com.,n3.domain.com.'
           ]),
        );

1 Answers1

0

You may wish to consider filing this issue with Google's public Issue Tracker.

You're not the first to encounter this and that question is 4 years old and remains unanswered :-(

Regardless of language SDK, the underlying call can be tested using Google's APIs Explorer and specifically ManagedZones:create which conveniently includes the relevant API method. You can plug in your values and try it out (securely) within the browser, or:

NAME="yourdomain-com"
DNS="yourdomain.com." # Must end with a period (.)

TOKEN=$(gcloud auth print-access-token)

curl \
--request POST \
--header "Authorization: Bearer ${TOKEN}" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data "{\"nameServerSet\":\"n1.domain.com.,n2.domain.com.\",\"name\":\"${NAME}\",\"dnsName\":\"${DNS}\",\"description\":\"\"}" \
"https://dns.googleapis.com/dns/v1/projects/${PROJECT}/managedZones"

I tried to craft a request using nameServerSet using the API directly and am unable. It's thus not a language SDK issue but a question of whether|how this property may be set.

It's somewhat interesting to note that you can't set name servers when creating zones through the console (link). But, you may subsequently change them. The console POSTs to ManagedZone:changes, e.g.:

POST https://www.googleapis.com/dns/v1beta2/projects/${PROJECT}/managedZones/${NAME}/changes
{
  "additions": [
    {
      "name": "...",
      "type": "NS",
      "ttl": 21600,
      "rrdatas": [
        "ns-cloud-d1.googledomains.com.",
        "ns-cloud-d3.googledomains.com.",
        "ns-cloud-d4.googledomains.com."
      ]
    }
  ],
  "deletions": [
    {
      "name": "...",
      "type": "NS",
      "ttl": 21600,
      "rrdatas": [
        "n1.domain.com.",
        "n2.domain.com.",
        "n3.domain.com."
      ]
    }
  ]
}

DazWilkin
  • 32,823
  • 5
  • 47
  • 88