Skip to content

Instantly share code, notes, and snippets.

Last active Sep 13, 2020
What would you like to do?
Export AWS Route53 Domains to a CSV for Excel people
# Export AWS Route53 Domains to a CSV for Excel people
# Usage:
# python3 <(wget -q -O -
from itertools import chain, starmap
import pandas as pd
from import json_normalize #package for flattening json in pandas df
import boto3
listofdomains = []
client = boto3.client('route53domains', region_name='us-east-1')
p = client.get_paginator('list_domains')
for page in p.paginate():
for domain in page['Domains']:
domain_detail = client.get_domain_detail(DomainName=domain['DomainName'])
# Remove response data, so it doesn't make it into the spreadsheet
del domain_detail['ResponseMetadata']
# Re-map "ExtraParams" to flatten the JSON for the spreadsheet
for c in ['RegistrantContact', 'TechContact', 'AdminContact']:
for p in domain_detail[c]['ExtraParams']:
domain_detail[c][p['Name']] = p['Value']
del domain_detail[c]['ExtraParams']
df = pd.json_normalize(listofdomains)
df.to_csv (r'domains.csv', index = False, header=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment