Yoni
Yoni

Reputation: 440

Python boto3 route53

I am trying to define an NS record with 3 entries, but I can't find the correct way to do it. can't assign the correct type of value that will work.

client = boto3.client('route53')
cluster_name="myserver.com"
for x in range(1, 4):
    node = "node" + str(x) + "." + cluster_name
    print(node)
    response = client.change_resource_record_sets(
        HostedZoneId='Z3Q8SD6RN2TO8XY1XXX',
        ChangeBatch={
            'Comment': '',
            'Changes': [
                {
                    'Action': 'UPSERT',
                    'ResourceRecordSet': {
                        'Name': node,
                        'Type': 'NS',
                        'TTL': 300,
                        'ResourceRecords': [
                            {
                                'Value': first node,
                                'Value': second_node,
                                'Value': third_node,
                            },
                        ],
                    }
                },
            ]
        }
    )

Upvotes: 0

Views: 324

Answers (1)

f7o
f7o

Reputation: 663

The ResourceRecord needs to be a List of objects with the syntax {"Value": "entry"}.

All in all it should look like this:

response = client.change_resource_record_sets(
        HostedZoneId='Z3Q8SD6RN2TO8XY1XXX',
        ChangeBatch={
            'Comment': '',
            'Changes': [
                {
                    'Action': 'UPSERT',
                    'ResourceRecordSet': {
                        'Name': node,
                        'Type': 'NS',
                        'TTL': 300,
                        'ResourceRecords': [
                            {
                                'Value': first node
                            },{
                                'Value': second_node
                            },{
                                'Value': third_node,
                            }
                        ],
                    }
                },
            ]
        }
    )

See the official documenation: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/route53.html#Route53.Client.change_resource_record_sets

Upvotes: 1

Related Questions