When you want to migrate DNS domains to AWS Route53, you need to migrate the content of
your domain name servers first. In this blog, I will introduce you to a small utility which
helps you to do just that!
AWS Route53 is a managed domain name server service, with a 100% uptime guarantee. To get that,
you need to create a DNS managed zone in Route53 and recreate all dns records. But migrating dns records is tricky. If you make a mistake, your systems may be down for prolonged periods of time.
To reduce the probability of errors, we created the
zonefile-migrate utility. The tool
parses a zonefile and generates a Cloudformation template.
In this way, you can reliability migrate your domain names to Route53 in three simple steps:
- request the zonefiles from your registrar
- convert the zonefiles to Cloudformation
- deploy the managed zones.
It is as simple as that. After this, you can change the name server registration and start the
domain name transfer process.
request the zonefiles
Normally you request the zonefiles at your registrar. In this case, we use our two example
domains: asample.or and land-5.com. To download these, type:
$ git clone https://gitlab.com/binxio/zonefile-migrate.git $ cd zonefile-migrate/example
convert to Cloudformation
To convert the zonefiles to Cloudformation, type:
$ zonefile-migrate to-cloudformation --sceptre-group config/dns ./zones ./templates/dns INFO: reading zonefile zones/asample.org INFO: reading zonefile zones/land-5.com
As a Cloudformation template is created for each domain, we also generate a Sceptre stack group for easy deployment.
deploy the managed zones
To deploy these managed zones to your AWS account, 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 ...
That is it. It is that simple!
To install the utility, type:
pip install zonefile-migrate
After you successfully created the managed zones, you can change the nameservers at your registrar and optionally move the registration of the domain to AWS too.
By using zonefiles to generate the Cloudformation template, you
minimize the potential for errors when migrating domain names to AWS Route53. As an
extra bonus, you have the basis for maintaining your zones as code!
If you need to migrate to Google Cloud DNS, read here how to!
Image by Gordon Johnson from Pixabay