Adding Multiple MX Records via AWS Route53 - changeResourceRecordSet - PHP

2k views Asked by At

I'm having a problem with the changeResourceRecordSets API call.

My record has multiple MX values. When I call the API I can get it to add 1 MX record, but I cannot get it to add multiple values.

For example:

   ['ResourceRecordSet']['Name'] = 'mytest.com'; 
   ['ResourceRecordSet']['Type'] = 'MX';
   ['ResourceRecordSet']['TTL'] = 3600;
   ['ResourceRecordSet']['ResourceRecords']['Value'] = array("Value"=>'10 mx1.emailsrvr.com');

Works for one record.

I've tried:

   ['ResourceRecordSet']['ResourceRecords']['Value'] = array("Value"=>'10 mx1.emailsrvr.com', '20 mx2.emailsrvr.com');

But this will only add one record, not both.

How do I add both records?

1

There are 1 answers

0
Chris Williams On BEST ANSWER

The official AWS documentation states that each value would be its own array, so the structure would look similar to the below

['ResourceRecordSet']['ResourceRecords'][] = array("Value"=>'10 mx1.emailsrvr.com');
['ResourceRecordSet']['ResourceRecords'][] = array("Value"=>'5 mx2.emailsrvr.com');

ResourceRecords is actually an array of values, rather than needing a key of "Value". Each of these will be looped over and added to your record.