Skip to content

Instantly share code, notes, and snippets.

@madsheep
Last active December 27, 2015 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madsheep/7249547 to your computer and use it in GitHub Desktop.
Save madsheep/7249547 to your computer and use it in GitHub Desktop.
Quick and a bit dirty solution for sync'ing all your DNS BIND files to route53
cli53 = '/home/ubuntu/.local/bin/cli53'
zones_on_aws = `#{cli53} list`.lines.select{|e| e =~ /Name/ }.map{|e| e.split(":").last.strip.sub(/\.$/, '') }
Dir.glob('zones/*.bind').each do |zone|
zone_name = File.basename(zone, '.bind')
unless zones_on_aws.include?(zone_name)
system("#{cli53} create #{zone_name}")
puts "#{zone_name} created."
end
abort("Can't sync #{zone_name}...") unless system("#{cli53} import #{zone_name} --file #{zone} --replace")
puts("#{zone_name} synced.")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment