ShK
ShK

Reputation: 101

Missing field 'SetIdentifier' in Change when deleting/upserting with ChangeResourceRecordSets Boto3

I've struggled for a week trying to delete/upsert a simple Route 53 resource record with Boto3 v1.10.39.

My code:

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>}]
                }
            }
        ]
    }
)

Error msg:

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]

Troubleshoot steps:

  1. I've gone through all possible documentations (Boto3, AWSCLI, AWS developer guide), the 'SetIdentifier' field is only required when it's not a simple RR (weighted, multivalue, failover etc.):

    • SetIdentifier (string)

      Resource record sets that have a routing policy other than simple: An identifier that differentiates among multiple resource record sets that have the same combination of name and type, such as multiple weighted resource record sets named acme.example.com that have a type of A. In a group of resource record sets that have the same name and type, the value of SetIdentifier must be unique for each resource record set.

      For information about routing policies, see Choosing a Routing Policy in the Amazon Route 53 Developer Guide.

  2. Tried the same operation with AWS CLI, same error as calling with Boto3.

  3. Called list_resource_record_sets and verified there's no set identifier value exists.
  4. Tried to add 'SetIdentifier': None, 'SetIdentifier': '' and 'SetIdentifier': , none of them works, which make sense as the original RR doesn't have this property at all.

Environment:

I'm wondering if this is a bug from AWS API.

Upvotes: 2

Views: 2094

Answers (1)

ShK
ShK

Reputation: 101

Created an issue in Boto3 github and got help from them saying removing 'Region' attribute is going to fix my issue, and it works like a charm for my code once I do that.

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>}]
            }
        }
    ]
}

)

Upvotes: 5

Related Questions