- Published on
Export Route 53 Hosted Zone DNS Records to a File in Bulk to a Local Machine and Export Them to a New AWS Account
- Authors
- Name
With AWS Command Line Interface (AWS CLI) & the CLI53 Tool
Photo by John Simmons on Unsplash
To export DNS records from an existing Route 53 hosted zone to a file and then import them into a new account, we can use the AWS Command Line Interface (AWS CLI) and the cli53
tool. Here are the general steps:
Export DNS Records:
- Install the
cli53
tool. We can install it using “pip” or “brew”:
pip install cli53 or brew install cli53
- Export DNS records from the old Route 53 hosted zone:
cli53 export — full old-domain.com > my-dns-records-export.txt
Replace old-domain.com
with your actual domain.
- The “my-dns-records-export.txt” file now contains the exported DNS records. To verify run;
cat my-dns-records-export.txt
Photo by Ray Harrington on Unsplash
Import DNS Records:
Install the AWS CLI on your new machine if you haven’t already.
Configure the AWS CLI with credentials for the new AWS account:
aws configure (then provide access keys and region details)Import DNS records into the new Route 53 hosted zone:
cli53 import — file dns-export.txt — replace — merge new-domain.com
OR
cli53 import — file aa-dns-export.txt — replace — upsert domain.com
OR
cli53 import — file my-dns-records-export2.txt — replace domain.com
OR
cli53 import — file my-dns-records-export2.txt — upsert domain.com
Replace new-domain.com
with your actual domain.
The — replace
option will replace all existing records in the hosted zone with the records from the file.
The — merge
option will add new records and update existing ones without deleting any records.
Ensure that the IAM user or role used by the AWS CLI has the appropriate permissions for the Route 53 actions (route53:ChangeResourceRecordSets
, route53:ListResourceRecordSets
, etc.).