I recently had to export all Route53 DNS entries, just to do some cleanup of them. I was surprised that there is no “official” way to export them all from the AWS console!
I found the cli53 tool, but it doesn’t do exactly what I need.
So, I decided to write my own powershell script. I share it with you, I hope it may help!
Feel free to send me your suggestions to make it better!
$zones = Get-R53HostedZoneList | select name,id,ResourceRecordSetCount | sort -Property name
foreach ($zone in $zones) {
[string]::Format(“[{0}] [{1}] ({2})”,$zone.Name, $zone.Id, $zone.ResourceRecordSetCount)
$recordsets = Get-R53ResourceRecordSet -HostedZoneId $zone.id
$recordsets = $recordsets.ResourceRecordSets | sort -Property type # | where type -EQ 'a'
foreach ($rs in $recordsets){
[string]::Format(“`n[{0}] [{1}] ({2})”,$rs.type, $rs.name, $rs.ResourceRecords.Count)
foreach ($record in $rs.ResourceRecords){
[string]::Format(" {0}", $record.Value)
}
}
"`n-----------------------------`n"
}
Thanks! The cli53 tool is nice but I love my PowerShell!