google-cloud-dns overview (2.7.0)

Stay organized with collections Save and categorize content based on your preferences.

A client for Cloud DNS - A highly available global DNS network.

Here are two simple usage examples from within Compute/App Engine.

The first snippet shows how to create a zone resource. The complete source code can be found on Note that you need to replace the domainName with a domain name that you own and the ownership of which you verified with Google.

 Dns dns = DnsOptions.getDefaultInstance().getService();
 String zoneName = "my-unique-zone";
 String domainName = "";
 String description = "This is a google-cloud-dns sample zone.";
 ZoneInfo zoneInfo = ZoneInfo.of(zoneName, domainName, description);
 Zone createdZone = dns.create(zoneInfo);

The second example shows how to create records inside a zone. The complete code can be found on

 Dns dns = DnsOptions.getDefaultInstance().getService();
 String zoneName = "my-unique-zone";
 Zone zone = dns.getZone(zoneName);
 String ip = "";
 RecordSet toCreate = RecordSet.newBuilder("", RecordSet.Type.A)
   .setTtl(24, TimeUnit.HOURS)
 ChangeRequestInfo changeRequest = ChangeRequestInfo.newBuilder().add(toCreate).build();

When using google-cloud from outside of App/Compute Engine, you have to specify a project ID and provide credentials. See Also: Google Cloud DNS