hands on Google DNS

Marcelo Barbosa
2 min readJul 12, 2017

A normal day I was under the protection of my headphones thinking about some ideas like kubernetes clusters, continuous integration, continuous deployment was when I received the mission: We could migrate to Google DNS!
Almost instantly I started thinking about my requirements for this migration:

* Create an Infrastructure as a code

* Document all zones and records

* Easy reproducibility

With my requirements in the mind I thought: I need create a tool to make this communication between my DNS data and Google DNS.
That’s when I looked at the Google DNS API documentation and realized that Python 3 was supported by the libraries that allowed this connection, this can be a lot of fun. I began to think about how tedious it was to read configuration files from the zones and how terrible that would be for an API communication. The data structure is one of the subjects that I never tire of studying.
Solutions such as NoSQL database have shown us the power that a JSON file with a simple key and value can have in storing and fetching data.
So I came up with the idea to solve the first two requirements of my mission: I can create the provisioning to Google DNS using the API. I can along with zones files have a versioning documented about what that was provisioned. In the future I can create the job in Jenkins to trigger any changes to master branch and provisioning a new records.

"zone": "example.com.",
"name": "name-of-your-zone-in-google-cloud-dns",
"description": "
example of DNS zone writed in JSON format",
"records": [
"name": "example.com.",
"type": "A",
"ttl": 3600,
"value": ["",
"name": "dns.example.com.",
"type": "CNAME",
"ttl": 3600,
"value": ["google.com."]

To reproduce with ease the tool should be able to run as in command line. The life can always be more fun when use Python 3.
I created open source tool shared below. I hope that if you have read so far it means that have a chance to receive a star in this repository, maybe adding feature, complain about some issue, please enjoy.