Created
April 5, 2023 15:29
-
-
Save gurchik/678b08fd62466434c8f94dcd5f976fef to your computer and use it in GitHub Desktop.
List all AWS Route 53 Records in all Hosted Zones
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 | |
client = boto3.client('route53') | |
def get_zones(): | |
paginator = client.get_paginator("list_hosted_zones") | |
for page in paginator.paginate(): | |
yield from page["HostedZones"] | |
def get_records(zone_id): | |
paginator = client.get_paginator("list_resource_record_sets") | |
for page in paginator.paginate(HostedZoneId=zone_id): | |
yield from page["ResourceRecordSets"] | |
zones = get_zones() | |
for zone in zones: | |
records = get_records(zone["Id"]) | |
for record in records: | |
print(f"{zone['Name']} - {record['Type']} - {record['Name']}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment