Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting DNS zonefile from Amazon Route 53

I would like to export a DNS zonefile from my Amazon Route 53 setup. Is this possible, or can zonefiles only be created manually? (e.g. through http://www.zonefile.org/?lang=en)

like image 523
casparjespersen Avatar asked Dec 02 '13 21:12

casparjespersen


People also ask

How do I create a CNAME record on AWS Route 53?

Add a CNAME Record to Your Amazon Route 53 Hosted DomainOnce logged in, click the hamburger menu icon on the left-hand side, and menu options will appear. Select Hosted zones from the left-hand side menu option. Select the domain name that you'd like to update with a CNAME record.

What are DNS records Route 53?

Route 53 provides an extension to DNS functionality known as alias records. Similar to CNAME records, alias records let you route traffic to selected AWS resources, such as CloudFront distributions and Amazon S3 buckets.


1 Answers

The following script exports zone details in bind format from Route53. Pass over the domain name as a parameter to script. (This required awscli to be installed and configured.)

#!/bin/bash  zonename=$1 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"' 
like image 156
Szentmarjay Tibor Avatar answered Sep 23 '22 16:09

Szentmarjay Tibor