-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup_route53_settings.py
38 lines (32 loc) · 1.03 KB
/
backup_route53_settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import json
import boto3
from boto3.session import Session
profile = '<your profile name>'
session = Session(profile_name=profile)
route53Client = session.client('route53')
def convertToJson(dictSource):
return json.dumps(dictSource, indent=4, separators=(',', ': '))
def listHostedZones():
result = []
response = route53Client.list_hosted_zones()
for hostedZone in response["HostedZones"]:
result.append(hostedZone)
return result
def printInfo(hostedZone,recordSets):
hostedZone["recordSets"] = recordSets
print('{},'.format(convertToJson(hostedZone)))
def main():
hostedZones = listHostedZones()
if( not hostedZones ):
print("not found hosted zone.")
exit()
print('"hostedZones": [')
for hostedZone in hostedZones:
response = route53Client.list_resource_record_sets(
HostedZoneId=hostedZone["Id"]
)
recordSets = response["ResourceRecordSets"]
printInfo(hostedZone, recordSets)
print(']')
if __name__ == '__main__':
main()