I'm using the AWS Route 53 Java SDK 2 software.amazon.awssdk:software.amazon.awssdk:route53:2.8.3 with OpenJDK 11 on Windows 10. I want to set two separate MX records with different priorities, e.g.
10 smpt1.example.com.20 smpt2.example.com.
If I set those as separate resource records, the last one overrides the first one, so that I only wind up with 20 smpt2.example.com. I read on an AWS forum thread that I need to combine the values into one resource record, with each MX record on a separate line, so I tried setting combining the values using "\n" (e.g. joining them with a newline character):
10 smpt1.example.com.
20 smpt2.example.com.
However that produces an error:
… software.amazon.awssdk.services.route53.model.InvalidChangeBatchException: [Invalid Resource Record: FATAL problem: MXRRDATANotTwoFields (MX record doesn't have 2 fields) encountered with '10 smtp1.example.com.
20 smtp2.example.com.'] (Service: Route53, Status Code: 400, Request ID: …
(Note that the error output starts 20.smtp2.example.com on a new line, indicating that there is a newline character. The Stack Overflow formatter above was removing the newline, so I added an extra blank line to illustrate. The blank line does not occur in the actual error message.)
So I'm stuck. How do I set two MX domains with different priorities in Route 53 using the Java SDK 2?
Update: This seems to be a pretty big blocker issue. Surely it can't be that Route 53 doesn't handle multiple MX records using the Java SDK 2. Is it completely broken? I've opened Issue #1484 with no responses so far.