Managing AWS Route53 with Fog

Skip to first unread message

Brett Cave

Aug 28, 2015, 9:48:24 AM8/28/15
to ruby-fog
Hi, I am trying to use Fog to manage Route53 zones / records. I came across this post, which covered some of it:!topic/ruby-fog/uObTJlynbUI

I wanted to confirm whether this was me using it incorrectly vs limited functionality of the library.

Use Case: Modify the SOA record of a domain by name (in-place edit, not a "destroy" and "create" - haven't tried this approach, and not going to as I don't think SOA can be removed or should be)

    require 'fog'
    dns ={ ... <connection params>})
    zone = { |zone| zone.domain == "" } [0]
    soaRecord = zone.records.get("", record_type = "SOA") # soaRecord.value[0] = " 1 7200 900 1209600 86400"
    soaRecord.value = [soaRecord[0].value.gsub(/ [0-9]+$/, " #{newttl}") # the ttl has now been changed on the soaRecord from 86400 to 3600.
   Fog::DNS::AWS::Error: InvalidChangeBatch => Tried to create resource record set [name='', type='SOA'] but it already exists

I'm looking through the change_resource_record_sets.rb now...

Frederick Cheung

Aug 28, 2015, 10:00:23 AM8/28/15
to, Brett Cave
Route53 is a little particular - updates are represented as a transaction consisting of destroy + create. 

it looks like the modify method on Fog::AWS::DNS::Record handles that for you 

You received this message because you are subscribed to the Google Groups "ruby-fog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

Brett Cave

Aug 28, 2015, 10:35:19 AM8/28/15
to Frederick Cheung,
Great, thanks Fred.

soaRecord.modify({value:[soaRecord[0].value.gsub(/ [0-9]+$/, " #{newttl}")]})

Brett Cave | System Architect

T: +27 11 523 3083 | M: +27 82 498

© 2015 Jemstep Inc. All rights reserved. | A: 75 Grayston Drive, Morningside Ext 05, Sandton, Johannesburg, South Africa

Reply all
Reply to author
0 new messages