AWS Route53 のレコード設定 Routing Policy を Simple -> Weight にしたい。
AWS Route53でのレコードの作成、削除、変更するスクリプトをPython(boto3を使用しています。)で作っています。
Documentを見ながら試しているのですが、
事前に作成した Aレコード Routing Policy: Simple を
Routing Policy: weight 50 setIdentifier: id01 へ変更したいです。
しかし、以下のようなエラーメッセージがありました。
発生している問題・エラーメッセージ
botocore.errorfactory.InvalidChangeBatch: An error occurred (InvalidChangeBatch) when calling the ChangeResourceRecordSets operation: RRSet with DNS name test.hogehoge.net., type A, SetIdentifier id01 cannot be created as a non-weighted set exists with the same name and type.
既にレコードが存在しているので、作成することができない。のような感じだと思うのですが、このような場合はDELETEしてからCREATEするような流れで作り直す必要があるでしょうか。
UPSERTで変更をかけることができれば良いと考えております。
該当のソースコード
既にAレコードの test.hogeoge.net が作成されている前提となります。
python
1import boto3 2 3client = boto3.client( 4 'route53', 5 aws_access_key_id='********', 6 aws_secret_access_key='*********', 7) 8 9response = client.change_resource_record_sets( 10 HostedZoneId="*****", 11 ChangeBatch={ 12 "Comment": "******", 13 "Changes": [ 14 { 15 "Action": "UPSERT", 16 "ResourceRecordSet": { 17 "Name": "test.hogehoge.net", 18 "Type": "A", 19 "SetIdentifier": "id01", #追加 20 "Weight": 50, # 追加 21 "TTL": 60, 22 "ResourceRecords": [ 23 { 24 "Value": "192.168.1.100" 25 }, 26 ], 27 } 28 }, 29 ] 30 } 31)
DELETEとCREATEを使うのは大変面倒だなと考えております。解決方法などありましたらご教示いただければと思います。よろしくお願いいたします。
あなたの回答
tips
プレビュー