Created
March 6, 2023 11:23
-
-
Save MattHealy/39816f652c49e2c33bf0cd3ca966c3ed to your computer and use it in GitHub Desktop.
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
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