wallix / awless

A Mighty CLI for AWS
http://awless.io/
Apache License 2.0
4.97k stars 263 forks source link

Backing up route 53 records and restoration ? #253

Open rgarrigue opened 5 years ago

rgarrigue commented 5 years ago

Hi

Just wanted to know if anyone tried to backup & restore route 53 zones and records using awless ? I know I can awless list records --output=json, but not sure if I can re-create from this json. Anyone got any experience on this ?

Best regards,

ljluestc commented 11 months ago
import json
import subprocess

with open('route53_backup.json', 'r') as file:
    data = json.load(file)

for zone in data['Zones']:
    zone_id = zone['Id']
    records = zone['Records']

    for record in records:
        record_type = record['Type']
        name = record['Name']
        value = record['Value']

        cmd = f"awless create record -z {zone_id} -t {record_type} -n {name} -v {value}"
        subprocess.call(cmd, shell=True)