Last active
December 27, 2015 01:59
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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