Skip to content

backing up aws route53 settings( all HostedZones and RecordSets )

License

Notifications You must be signed in to change notification settings

skatsumata/backup_route53_settings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Overview

route53の全てのHostedZoneとレコードセットの設定をJson形式で取得するPythonスクリプトです。

This is a Python script that gets all HostedZone and Recordset settings of route53 in Json format.

Hosted zones

Record Set

environment

# version
OS CentOS 7.5.1804
python 2.7.5
boto3 1.9.33

Configuration

実行する端末にAWSプロファイル($ aws configure --profile your-profile-name)が設定されている必要があります。
このユーザには、ListResourceRecordSets,ListHostedZones 権限が付与されている必要があります。

A terminal that runs this script must have an AWS profile set up. The user specified in this profile must have ListResourceRecordSets, ListHostedZones privilege granted.

profile = '<your profile name>'
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "route53:ListResourceRecordSets",
            "Resource": "arn:aws:route53:::hostedzone/*"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": "route53:ListHostedZones",
            "Resource": "*"
        }
    ]
}

usage

スクリプトを実行すると後述したようにコンソール出力されるのでリダイレクトしてファイルに格納する想定です。

$ python backup_route53_settings.py > route53_settings.txt

output sample

"hostedZones": [
{
    "Id": "/hostedzone/xxxxxxxx"
    "Name": "example.com.",
    "Config": {
        "Comment": "\u4f1a\u793e\u30db\u30fc\u30e0\u30da\u30fc\u30b8",
        "PrivateZone": false
    },
    "CallerReference": "D00D4DCE-876F-CEBF-87C3-B698F213C668",
    "ResourceRecordSetCount": 15,
    "recordSets": [
        {
            "ResourceRecords": [
                {
                    "Value": "158.199.141.166"
                }
            ],
            "Type": "A",
            "Name": "example.com.",
            "TTL": 300
        },
        { ... }
     ]
},{
    ... 省略 ...
}

boto3 documents

About

backing up aws route53 settings( all HostedZones and RecordSets )

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages