Written by James McDonald

December 18, 2019

Just completed a migration away from AWS to Digital Ocean

Need to install the Digital Ocean dotctl command line utility (this is using brew on a mac)

brew install dotctl

Transfer domain records away from AWS using the aws-cli

#!/bin/bash

domains=$(aws route53 list-hosted-zones | jq '.HostedZones[].Name' | sed -E 's/\.*\"//g')

for i in $domains; do
    zonename=$i
    hostedzoneid=$(aws route53 list-hosted-zones --output json | jq -r ".HostedZones[] | select(.Name == \"$zonename.\") | .Id" | cut -d'/' -f3)
    aws route53 list-resource-record-sets --hosted-zone-id $hostedzoneid --output json | jq -jr '.ResourceRecordSets[] | "\(.Name) \t\(.TTL) \t\(.Type) \t\(.ResourceRecords[].Value)\n"' >zone-file-${i}
done

With the exported zone files use them to create a scripted DNS transfer. I have commented out the zone records and interspersed them with the doctl commands

doctl compute domain delete ausfoodexports.com.au
doctl compute domain create ausfoodexports.com.au

doctl compute domain records create --record-type A --record-name @ \
    --record-data 167.71.215.46 ausfoodexports.com.au

doctl compute domain records create --record-type AAAA --record-name @ \
    --record-data 2400:6180:0:d1::841:e001 ausfoodexports.com.au

# ausfoodexports.com.au. 	300 	A 	13.55.162.0
# ausfoodexports.com.au. 	300 	AAAA 	2406:da1c:f72:aa73:f84e:74fa:4f91:e542
# ausfoodexports.com.au. 	3600 	MX 	0 ausfoodexports-com-au.mail.protection.outlook.com.
doctl compute domain records create --record-type MX --record-name @ \
    --record-priority 0 --record-data "ausfoodexports-com-au.mail.protection.outlook.com." ausfoodexports.com.au

# ausfoodexports.com.au. 	172800 	NS 	ns-41.awsdns-05.com.
# ausfoodexports.com.au. 	172800 	NS 	ns-1686.awsdns-18.co.uk.
# ausfoodexports.com.au. 	172800 	NS 	ns-717.awsdns-25.net.
# ausfoodexports.com.au. 	172800 	NS 	ns-1515.awsdns-61.org.
# ausfoodexports.com.au. 	900 	SOA 	ns-1686.awsdns-18.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400
# ausfoodexports.com.au. 	3600 	TXT 	"MS=ms47011853"
doctl compute domain records create --record-type TXT --record-name @ \
    --record-data "MS=ms47011853" ausfoodexports.com.au

# ausfoodexports.com.au. 	3600 	TXT 	"v=spf1 include:spf.protection.outlook.com -all"
doctl compute domain records create --record-type TXT --record-name @ \
    --record-data "v=spf1 include:spf.protection.outlook.com -all" ausfoodexports.com.au
# autodiscover.ausfoodexports.com.au. 	3600 	CNAME 	autodiscover.outlook.com.

doctl compute domain records create --record-type CNAME --record-name autodiscover \
    --record-data "autodiscover.outlook.com." ausfoodexports.com.au

# www.ausfoodexports.com.au. 	300 	CNAME 	ausfoodexports.com.au.
doctl compute domain records create --record-type CNAME --record-name www \
    --record-data "ausfoodexports.com.au." ausfoodexports.com.au

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…