Created
October 23, 2012 08:26
-
-
Save mechamogera/3937629 to your computer and use it in GitHub Desktop.
起動中のEC2インスタンスを検出するスクリプト
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
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