Created
February 27, 2012 16:36
-
-
Save thattommyhall/1925229 to your computer and use it in GitHub Desktop.
List servers in all EC2 regions
This file contains hidden or 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
require 'fog' | |
AWS = Fog::Compute.new(:provider => 'AWS') | |
REGIONS = AWS.describe_regions.body["regionInfo"].map {|region| region["regionName"]} | |
COMPUTE = {} | |
REGIONS.each do |region| | |
COMPUTE.merge!(region => Fog::Compute.new({:provider => 'AWS', :region=>region})) | |
end | |
COMPUTE.each_pair do |region,connection| | |
puts "***#{region}***" | |
availability_zones = connection.describe_availability_zones.body["availabilityZoneInfo"].map{|zone| zone["zoneName"]} | |
availability_zones.each do |zone| | |
puts "**#{zone}**" | |
puts connection.servers.select{|server| server.availability_zone == zone}.map{|server| server.tags["Name"]} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment