Skip to content

Instantly share code, notes, and snippets.

@mechamogera
Created August 8, 2012 12:27
Show Gist options
  • Save mechamogera/3294772 to your computer and use it in GitHub Desktop.
Save mechamogera/3294772 to your computer and use it in GitHub Desktop.
全てのEC2インスタンスのDNS名とタグ表示
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 = ec2.regions['ap-northeast-1']
ec2.instances.each do |x|
puts x.dns_name
x.tags.each do |tag|
puts "\t#{tag[0]}, #{tag[1]}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment