How do I create a route53 record set using the aws sdk for ruby?


EC2 gives instances a new IP address when they’re stopped then restarted, so I need to be able to automatically manage a route53 record set so that I can access things consistently. Sadly the documentation for the route53 portion of the sdk is not nearly as robust as it is for ec2 (understandably) and so I’m a bit stuck. From what I’ve seen so far, it seems like change_resource_record_sets (link) is the way to go, but I’m confused as to what needs go into :chages since it mentions a Change object but fails to provide a link to a description of said object.

Here’s what my code currently looks like for a creation:

EDIT: Okay, since I haven’t had any help either here or on the official forums I’ve been messing around with it myself. So it turns out that the documentation is just plain awful. All of the values are stored in a Change object, and not given there. So it actually looks more like this:


The documentation is pretty poor, though it does contain a few examples. I initially had the impression that it was necessary to create requests (and use the client object) per your solution, but there are alternatives.

An example of creating a record can be found in the ResourceRecordSetCollection reference, but it’s only a little more concise than your answer:

I wanted to update an existing record, and didn’t have the hosted_zone_id to hand. It took far too long to figure out how best to do this, so I’m offering the following example in the hope it saves someone else some time:

Note that that assumes you only have a single zone with that name in Route53.

Leave a Reply