Skip to content

Instantly share code, notes, and snippets.

@jhohertz
Created August 20, 2014 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhohertz/eb24942af0a93b4f2561 to your computer and use it in GitHub Desktop.
Save jhohertz/eb24942af0a93b4f2561 to your computer and use it in GitHub Desktop.
Quick and dirty script to export route53 resource records to zone format
#!/usr/bin/python
# Script takes the output of:
#
# aws route53 list-resource-record-sets --hosted-zone-id <zone ID> | rrset-to-zone.py
#
# And converts all the standard records to normal DNS zone lines, and everything else, a warning
#
import sys, json, pprint
rrset = json.load(sys.stdin)
for rr in rrset['ResourceRecordSets']:
if "ResourceRecords" in rr:
name = rr['Name']
t = rr['Type']
ttl = rr['TTL']
for rec in rr['ResourceRecords']:
val = rec['Value']
if t == "CNAME":
val += "."
print "%s\t%s\tIN %s\t%s" % (name, ttl, t, val)
else:
print ";; ######## Not a RR: %s" % rr['Name']
@olevenkov
Copy link

How is this script connecting to AWS?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment