使用boto3发布更新route53记录集

时间:2018-09-19 19:49:43

标签: python python-3.x amazon-web-services boto3 amazon-route53

我正在尝试使用以下命令将现有记录集的值修改为“ SetIdentifier”和“ DNSName”。

client = boto3.client('route53',
                         aws_access_key_id=my_key_id,
                         aws_secret_access_key=my_access_key,
                         region_name='us-west-2'
                         )
response = client.change_resource_record_sets(
        HostedZoneId=hosted_zoneId,
        ChangeBatch={
            'Comment': 'test-1.2',
            'Changes': [
                {
                    'Action': 'UPSERT',
                    'ResourceRecordSet': {
                        'Name': record_name,
                        'Type': record_type,
                        'SetIdentifier': 'test-active12',
                        'Region': 'us-west-2',
                        'AliasTarget': {
                            'HostedZoneId': hosted_zoneId,
                            'DNSName': 'active12.server.net.',
                            'EvaluateTargetHealth': False
                        }
                    }
                },
            ]
        }
    )

运行上面的命令时出现以下错误,并且当记录集不存在时,上面的命令也可以工作:

Traceback (most recent call last):
  File "test-route53.py", line 51, in <module>
    'EvaluateTargetHealth': False
  File "C:\Python27\lib\site-packages\botocore-1.8.49-py2.7.egg\botocore\client.py", line 324, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "C:\Python27\lib\site-packages\botocore-1.8.49-py2.7.egg\botocore\client.py", line 622, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.InvalidChangeBatch: An error occurred (InvalidChangeBatch) when calling the ChangeResourceRecordSets operation: RRSet with DNS name test.server.net., type A, SetIdentifier test-active12, and Region Name=us-west-2 cannot be created because a latency RRSet with the same name, type and region already exists.

0 个答案:

没有答案