【问题标题】:Missing field 'SetIdentifier' in Change when deleting/upserting with ChangeResourceRecordSets Boto3使用 ChangeResourceRecordSets Boto3 删除/更新插入时,更改中缺少字段“SetIdentifier”
【发布时间】:2020-04-09 08:42:36
【问题描述】:

我已经挣扎了一个星期,试图使用 Boto3 v1.10.39 删除/更新一个简单的 Route 53 资源记录。

我的代码:

resp=r53_client.change_resource_record_sets(
    HostedZoneId=<ZONE_ID>,
    ChangeBatch={
        'Comment': 'del_ip',
        'Changes': [
            {
                'Action': 'DELETE',
                'ResourceRecordSet': {
                    'Name': <SUBDOMAIN>,
                    'Type': 'A',
                    'Region': 'us-east-1',
                    'TTL': 300,
                    'ResourceRecords': [{'Value': <OLD_IP>}]
                }
            }
        ]
    }
)

错误信息:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/botocore/client.py", line 272, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/lib/python2.7/dist-packages/botocore/client.py", line 576, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.InvalidInput: An error occurred (InvalidInput) when calling the ChangeResourceRecordSets operation: Invalid request: Missing field 'SetIdentifier' in Change with [Action=DELETE, Name=<SUBDOMAIN>., Type=A, SetIdentifier=null]

问题排查步骤:

  1. 我浏览了所有可能的文档(Boto3、AWSCLI、AWS 开发人员指南),“SetIdentifier”字段仅在不是简单的 RR(加权、多值、故障转移等)时才需要:

    • SetIdentifier(字符串)

      具有路由策略非简单的资源记录集:用于区分具有相同名称和类型组合的多个资源记录集的标识符,例如名为 acme.example 的多个加权资源记录集。 com 类型为 A。在一组具有相同名称和类型的资源记录集中,SetIdentifier 的值对于每个资源记录集必须是唯一的。

      有关路由策略的信息,请参阅 Amazon Route 53 开发人员指南中的 Choosing a Routing Policy

  2. 尝试使用 AWS CLI 进行相同的操作,与使用 Boto3 调用时出现相同的错误。

  3. 调用 list_resource_record_sets 并验证不存在任何集合标识符值。
  4. 尝试添加 'SetIdentifier': None, 'SetIdentifier': '' 和 'SetIdentifier': ,它们都不起作用,这是有道理的,因为原始 RR 根本没有这个属性。

环境:

  • 操作系统:amzn-ami-hvm-2015.09.1.x86_64-gp2

  • Python:v2.7.14

  • BOTO3:v1.10.39

  • botocore:1.13.39

  • aws-cli:v1.16.301

我想知道这是否是来自 AWS API 的错误。

【问题讨论】:

    标签: python-2.7 boto3 aws-cli amazon-route53


    【解决方案1】:

    在 Boto3 github 中创建了一个问题,并从他们那里得到帮助,说删除“区域”属性将解决我的问题,一旦我这样做,它就像我的代码的魅力一样。

    resp=r53_client.change_resource_record_sets(
    HostedZoneId=<ZONE_ID>,
    ChangeBatch={
        'Comment': 'del_ip',
        'Changes': [
            {
                'Action': 'DELETE',
                'ResourceRecordSet': {
                    'Name': <SUBDOMAIN>,
                    'Type': 'A',
                    'TTL': 300,
                    'ResourceRecords': [{'Value': <OLD_IP>}]
                }
            }
        ]
    }
    

    )

    【讨论】:

      猜你喜欢
      • 2020-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-27
      • 1970-01-01
      • 2018-11-21
      相关资源
      最近更新 更多