Created
May 21, 2018 20:47
-
-
Save dgulinobw/72a427c2bd0f8572714d72491d6e0684 to your computer and use it in GitHub Desktop.
Lists All AWS Route53 resource records in a single account in column format
This file contains hidden or 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/env python | |
from __future__ import print_function | |
import json | |
import boto3 | |
domains_client=boto3.client('route53domains') | |
resource_client=boto3.client('route53') | |
paginator = resource_client.get_paginator('list_hosted_zones') | |
page_iterator = paginator.paginate() | |
ids=[] | |
for page in page_iterator: | |
hosted_zones = page["HostedZones"] | |
for zone in hosted_zones: | |
ids.append(zone['Id']) | |
records=[] | |
for id in ids: | |
paginator = resource_client.get_paginator('list_resource_record_sets') | |
page_iterator = paginator.paginate(HostedZoneId=id) | |
accum=[] | |
for page in page_iterator: | |
rrs = page["ResourceRecordSets"] | |
for rr in rrs: | |
records.append(rr) | |
#print(records[0]) | |
for record in records: | |
rr = record.get("ResourceRecords") | |
if rr == None: | |
values = None | |
else: | |
values = [value["Value"] for value in rr] | |
print("{} {} {}".format(record["Name"],record["Type"],values)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment