Skip to content

Instantly share code, notes, and snippets.

@bortels
Created March 6, 2013 00:48
Show Gist options
  • Save bortels/5095792 to your computer and use it in GitHub Desktop.
Save bortels/5095792 to your computer and use it in GitHub Desktop.
Experiments with aws ruby sdk for route53
#!/usr/bin/ruby
# Update route 53 DNS entry
require 'rubygems'
require 'aws-sdk'
AWS.config(YAML.load(File.read('credentials-file')))
zoneid = "unknown"
r53 = AWS::Route53.new
resp = r53.client.list_hosted_zones
resp[:hosted_zones].each do |zone|
puts(zone[:name] + ' ' + zone[:id] + zone[:config][:comment])
if (zone[:name] == "bortels.us.") then zoneid = zone[:id] end
end
# info on zone
zoneinfo = r53.client.get_hosted_zone({:id => zoneid})
# all records for zone
records = r53.client.list_resource_record_sets({:hosted_zone_id => zoneid})
# specific record for zone (actually, does not differentiate by type)
resp = r53.client.list_resource_record_sets({:hosted_zone_id => zoneid, :start_record_name => "test.bortels.us", :max_items => 1})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment