When moving infrastructure between AWS accounts, one common task is migrating DNS records in Amazon Route 53. Instead of manually copying records, we can export them from the source account and import them into the destination account. This ensures consistency and reduces the chance of misconfiguration. In this guide, we’ll walk through How to migrate a Route 53 domains and its records from one AWS account to another.
Prerequisites
- Access to both the source and destination AWS accounts.
- jq installed (used for JSON filtering).
Step 1: Create a New Hosted Zone in the Destination Account (Console)
- Log in to the AWS Management Console of the destination account.
- Navigate to Route 53 → Hosted Zones.
- Click Create hosted zone.
- Enter the domain name (e.g., example.com).
- Choose Public hosted zone (if the domain is internet-facing).
- Click Create hosted zone.
Note: This hosted zone will come with default NS and SOA records. Keep them as-is, since they’re needed.
Step 2: Export Records from the Source Account
Run the following command to list all DNS records in the source account:
aws route53 list-resource-record-sets \
--hosted-zone-id SOURCE_HOSTED_ZONE_ID \
> source-records.json
This file contains all records, including system ones like NS and SOA. We don’t want to overwrite those in the destination.
Step 3: Clean and Format the Records
Use jq to filter out NS and SOA records:
jq '{Changes: [.ResourceRecordSets[]
| select(.Type!="NS" and .Type!="SOA")
| {Action:"CREATE", ResourceRecordSet:.}]}' \
source-records.json > formatted-records.json
This generates a new file (formatted-records.json) containing only the records we need to migrate.
Step 4: Download the JSON File from CloudShell
1. In CloudShell, go to the Actions menu (top-right).
2. Select Download file.
3. Enter the filename (e.g., source-records.json).
4. Save it to your local computer.
Step 5: Upload the JSON File to the Destination Account
1. Switch to the destination AWS account.
2. Open CloudShell.
3. In the Actions menu, select Upload file.
4. Choose your formatted-records.json and upload it.
Step 6: Import Records into the Destination Account
Upload the new records to the hosted zone in the destination account:
aws route53 change-resource-record-sets \
--hosted-zone-id DESTINATION_HOSTED_ZONE_ID \
--change-batch file://formatted-records.json
This will create all DNS records in the new hosted zone.
Step 7: Verify the Import Status
Check whether the changes are applied:
aws route53 get-change --id CHANGE_ID
The CHANGE_ID comes from the response of the previous step. Once the status shows as INSYNC, the migration is complete.
Step 8: Update the Domain Registrar
If your domain is registered outside AWS, log in to your domain registrar and update the nameservers (NS) to match those provided by Route 53 in the destination hosted zone.
If your domain is registered in Route 53 itself, simply update the domain’s nameserver delegation to point to the new hosted zone in the destination account.
Step 9: Test Your DNS
Use tools like dig, nslookup, or online DNS checkers to confirm that your records are resolving correctly:
dig A example.com
nslookup mail.example.com
Conclusion
Migrating Route 53 hosted zones between AWS accounts involves exporting records from the source, cleaning them up, importing them into the destination, and updating the nameservers. By following this process, you ensure a smooth migration without downtime.
Need expert help to Migrate Route 53 Domains between AWS accounts seamlessly? Our team at Skynats specializes in AWS Management Services, ensuring smooth DNS transfers, zero downtime, and secure migrations. Contact us today for reliable support and hassle-free domain management