Managing AWS Route53 with Fog

172 views
Skip to first unread message

Brett Cave

unread,
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: https://groups.google.com/forum/#!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'
    newttl=3600
    dns = Fog::DNS::AWS.new({ ... <connection params>})
    zone = dns.zones.all.select { |zone| zone.domain == "mydomain.net." } [0]
    soaRecord = zone.records.get("mydomain.net.", record_type = "SOA") # soaRecord.value[0] = "ns-1234.awsdns.com. awsdns-hostmaster.amazon.com 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.
    soaRecord.save
  
   Fog::DNS::AWS::Error: InvalidChangeBatch => Tried to create resource record set [name='mydomain.net.', type='SOA'] but it already exists

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




Frederick Cheung

unread,
Aug 28, 2015, 10:00:23 AM8/28/15
to ruby...@googlegroups.com, 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 

Fred
--
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 ruby-fog+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brett Cave

unread,
Aug 28, 2015, 10:35:19 AM8/28/15
to Frederick Cheung, ruby...@googlegroups.com
Great, thanks Fred.

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


https://s3.amazonaws.com/static.us/webapp/email_signature/jemstep.jpg

Brett Cave | System Architect

T: +27 11 523 3083 | M: +27 82 498 4827br...@jemstep.com

https://s3.amazonaws.com/static.us/webapp/email_signature/Facebook.pnghttps://s3.amazonaws.com/static.us/webapp/email_signature/LinkedIn.pnghttps://s3.amazonaws.com/static.us/webapp/email_signature/Tweeter.pnghttps://s3.amazonaws.com/static.us/webapp/email_signature/GooglePlus.png

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


Reply all
Reply to author
Forward
0 new messages