Monday, February 17, 2014

Cloudformation, Route53 and MX records

I wasn’t able to find an example of how to create a Route 53 MX record via Cloudformation. I eventually figured it out, but it was confusing at first. MX records have a weight to them, and Cloudformation has a weight field. In this case you don’t use it though. Here’s what I figured out:

       "MXRecords" :
        {
            "Type" : "AWS::Route53::RecordSet",
            "Properties" : {
                "HostedZoneName" : { "Ref" : "SiteDNSName" },
                "Comment" : "MX records",
                "Name" : { "Ref" : "SiteDNSName" },
                "Type" : "MX",
                "TTL" : "60",
                "ResourceRecords" : [ { "Fn::Join" : [ "", [ "10 smtp.", { "Ref" : "SiteDNSName" } ] ] } ]
            },
            "DependsOn" : "ServerIP"
        }

The weight is actually in the text of the record. (10 in this example.).

No comments:

Post a Comment