さすがに手動で30個のエイリアスレコードをペアで
「確認お願いします!」
「はいOKです」
更新
x 30
というのはなんともエンジニアらしくないので、awscliを使って一気に追加してみました。
■AWS CLI を使用して Route 53 でエイリアスリソースレコードセットを作成する方法を教えてください。
https://aws.amazon.com/jp/premiumsupport/knowledge-center/alias-resource-record-set-route53-cli/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
{ "Comment": "Creating Alias resource record sets in Route 53", "Changes": [{ "Action": "CREATE", "ResourceRecordSet": { "Name": "elb.example.com", "Type": "A", "AliasTarget":{ "HostedZoneId": "Z1H1FL5HABSF5", "DNSName": "ALB-xxxxxxxx.us-west-2.elb.amazonaws.com", "EvaluateTargetHealth": false }} }] } |
1 |
$ aws route53 change-resource-record-sets --hosted-zone-id ZXXXXXXXXXX --change-batch file://sample.json |
jsonファイルを作って実行時に指定する感じですな。
■準備
- ~/aws/credentials
1 2 3 |
[adachin-aws] aws_access_key_id = Axxxxxxxxxxxxxx aws_secret_access_key = xxxxxxxxxxxxxxxxxxxxxxxxxx |
- 53.json
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 39 40 41 42 43 44 |
{ "Comment" : "", "Changes" : [ {"Action":"CREATE","ResourceRecordSet":{"Name":"dev0.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev1.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev2.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev3.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev4.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev5.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev6.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev0-hoge.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev1-hoge.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev2-hoge.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev3-hoge.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev4-hoge.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev5-hoge.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev6-hoge.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev0-fuga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev1-fuga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev2-fuga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev3-fuga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev4-fuga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev5-fuga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev6-fuga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev0-moga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev1-moga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev2-moga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev3-moga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev4-moga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev5-moga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev6-moga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev0-toga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev1-toga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev2-toga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev3-toga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev4-toga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev5-toga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}}, {"Action":"CREATE","ResourceRecordSet":{"Name":"dev6-toga.adachin.jp","Type":"A","AliasTarget":{"HostedZoneId":"xxxxxxxxxxxx","DNSName":"dualstack.rproxy-xxxxxxxx.ap-northeast-1.elb.amazonaws.com","EvaluateTargetHealth":false}}} ] } |
Nameだけ変更してもらって、HostedZoneIdはエイリアスホストゾーンIDを指定します。
- Syntaxチェック
1 2 |
$ jq . 53.json エラーでなければOK |
■実行
1 2 3 4 5 6 7 8 9 |
$ aws route53 change-resource-record-sets --hosted-zone-id xxxxxxxx --change-batch file://53.json --profile adachin-aws { "ChangeInfo": { "Id": "/change/xxxxxxxxxxxx", "Status": "PENDING", "SubmittedAt": "2019-05-07xxxxxxxxxxxxxxxx", "Comment": "" } } |
–hosted-zone-idはRoute53で対象ドメインのホストゾーンIDを指定しましょう。
■まとめ
実行したときの感動!!!
Terraformより楽でいいですな。
最近Terraform触ってない…(白目)
0件のコメント