Created
August 20, 2014 16:11
-
-
Save jhohertz/eb24942af0a93b4f2561 to your computer and use it in GitHub Desktop.
Quick and dirty script to export route53 resource records to zone format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How is this script connecting to AWS?