How to migrate zonefiles to the cloud

22 May, 2022

When you migrate domain names to the Cloud, you need to migrate the content of your name servers
too. In this blog I will introduce you to a small utility which helps you to do just that!

All cloud providers, act as a domain name registrar. When you transfer all your domains to your cloud provider,
you have two major benefits: Firstly, you get all the cost on a single invoice and secondly, you can
manage all of your managed zones through code.

However, when you have hunderds of domain names to transfer it is going to be really tricky to do this
without introducing any errors. As the domain name registration is essential for the availability of your
website, you want an automated process.

For this purpose we created the zonefile-migrate. The tool
parses a zonefile and either generates a AWS Cloudformation or
a Terraform template.

In this way, migrating a domain name becomes a reliable process: you request the zonefiles for your domains at your registrar, run the migrate, and apply the template. It is as simple as that.

Example – Cloudformation

In the source code we have an example, to try it out, type:

$ git clone
$ cd zonefile-migrate/example
$ zonefile-migrate to-cloudformation --sceptre-group config/dns ./zones ./templates/dns
INFO: reading zonefile zones/
INFO: reading zonefile zones/

To deploy all the managed zones to AWS, type:

$ sceptre --var aws_profile=$AWS_PROFILE launch -y dns
[2022-05-14 14:58:23] - dns/zone-land-5-com - Launching Stack
[2022-05-14 14:58:23] - dns/zone-example-org - Launching Stack
[2022-05-14 14:58:23] - dns/zone-land-5-com - Stack is in the PENDING state
[2022-05-14 14:58:23] - dns/zone-land-5-com - Creating Stack
[2022-05-14 14:58:23] - dns/zone-asample-org - Stack is in the PENDING state
[2022-05-14 14:58:23] - dns/zone-asample-org - Creating Stack
[2022-05-14 14:58:24] - dns/zone-asample-org binxio-dns-zone-asample-org AWS::CloudFormation::Stack CREATE_IN_PROGRESS User Initiated
[2022-05-14 14:58:24] - dns/zone-land-5-com binxio-dns-zone-land-5-com AWS::CloudFormation::Stack CREATE_IN_PROGRESS User Initiated

Example – Terraform

$ git clone
$ cd zonefile-migrate/example
$ zonefile-migrate to-terraform --provider google ./zones ./templates/dns
INFO: reading zonefile zones/
INFO: reading zonefile zones/

To deploy all the managed zones to Google Cloud Platform, type:

$ terraform init
$ export GOOGLE_PROJECT=$(gcloud config get-value core/project)
$ terraform apply -auto-approve
Terraform will perform the following actions:

# module.asample_org.google_dns_managed_zone.managed_zone will be created
+ resource "google_dns_managed_zone" "managed_zone" {
    + description   = "Managed by Terraform"
    + dns_name      = ""
    + force_destroy = false
    + id            = (known after apply)
    + name          = "asample-org"
    + name_servers  = (known after apply)
    + project       = (known after apply)
    + visibility    = "public"
Plan: 49 to add, 0 to change, 0 to destroy. Creating...
module.asample_org.google_dns_managed_zone.managed_zone: Creating...

That is it. It is that simple!


To install the utility, type:

pip install zonefile-migrate


By using zonefiles to generate either a AWS Cloudformation or
Terraform template, you minimize the potential for errors when
tranfering a large number of domain names to the Cloud. As an extra bonus, you have the basis for
maintaining your zones as code, and create CI/CD pipelines for the deployment of changes.

Image by Gordon Johnson from Pixabay

Mark van Holsteijn is a senior software systems architect at Xebia Cloud-native solutions. He is passionate about removing waste in the software delivery process and keeping things clear and simple.

Explore related posts