Skip to content

Instantly share code, notes, and snippets.

@charleskirk
Created October 25, 2012 15:48
Show Gist options
  • Save charleskirk/3953545 to your computer and use it in GitHub Desktop.
Save charleskirk/3953545 to your computer and use it in GitHub Desktop.
@full_list = Array.new
@list = @r53.client.list_hosted_zones
loop do
@list[:hosted_zones].each do |zone|
@full_list << zone
end
@next_marker = @list[:next_marker]
@list = @r53.client.list_hosted_zones({ :marker => @next_marker })
break if @list[:next_marker] == nil
end
required_records = ['A', 'CNAME', 'ALIAS']
@full_list.each do |zone|
records = @r53.client.list_resource_record_sets({:hosted_zone_id => zone[:id].gsub('/hostedzone/','')})
records.resource_record_sets.each do |record|
if required_records.include? record[:type]
new_record = {:name => record[:name], :record_type => record[:type], :set_identifier => record[:set_identifier],
:region => record[:region]}
if record.include?(:alias_target)
new_record[:alias_target_zone] = record[:alias_target][:hosted_zone_id]
new_record[:alias_target_dns_name] = record[:alias_target][:dns_name]
end
DnsRecord.create(new_record)
new_record = nil
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment