Skip to content

Instantly share code, notes, and snippets.

@mndoci
Forked from mechamogera/ec2_checker.rb
Created February 5, 2013 13:16
Show Gist options
  • Save mndoci/4714379 to your computer and use it in GitHub Desktop.
Save mndoci/4714379 to your computer and use it in GitHub Desktop.
gem 'aws-sdk'
require 'rubygems'
require 'aws-sdk'
ec2 = AWS::EC2.new(:access_key_id => nil,
:secret_access_key => nil,
:proxy_uri => ENV['HTTPS_PROXY'] || ENV['https_proxy'] || ENV['HTTP_PROXY'] || ENV['http_proxy'])
ec2.regions.each do |region|
reg = ec2.regions[region.name]
reg.instances.each do |instance|
if instance.status == :running
puts instance.tags["Name"] || instance.dns_name
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment