Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
全ての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