Skip to content

Instantly share code, notes, and snippets.

@MattHealy
Created March 6, 2023 11:23
Show Gist options
  • Save MattHealy/39816f652c49e2c33bf0cd3ca966c3ed to your computer and use it in GitHub Desktop.
Save MattHealy/39816f652c49e2c33bf0cd3ca966c3ed to your computer and use it in GitHub Desktop.
import boto3
import csv
client = boto3.client('route53domains', region_name='us-east-1')
fieldnames = [
'Domain Name',
'Domain Registrar',
'Expiration Date',
'Auto-Renewal',
'DNS Resolution Scope',
'DNS Hosting Service',
'Authoritative DNS Servers',
'Operational Status',
'Support Group',
]
outfilename = 'aws-domains.csv'
with open(outfilename, 'a', newline='') as writecsv:
writer = csv.DictWriter(writecsv, fieldnames=fieldnames, quoting=csv.QUOTE_ALL)
writer.writeheader()
response = client.list_domains(MaxItems=100)
for item in response['Domains']:
domain = client.get_domain_detail(
DomainName=item['DomainName']
)
dnsHost = 'N/A'
for n in domain['Nameservers']:
if 'awsdns' in n['Name']:
dnsHost = 'Route53'
break
row = {
'Domain Name': domain['DomainName'],
'Domain Registrar': domain['RegistrarName'],
'Expiration Date': domain['ExpirationDate'],
'Auto-Renewal': domain['AutoRenew'],
'DNS Resolution Scope': '',
'DNS Hosting Service': dnsHost,
'Authoritative DNS Servers': ','.join([n['Name'] for n in domain['Nameservers']]),
'Operational Status': '',
'Support Group': '',
}
writer.writerow(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment