Skip to content

Instantly share code, notes, and snippets.

@arukoh
Created March 31, 2014 05:11
Show Gist options
  • Save arukoh/9885708 to your computer and use it in GitHub Desktop.
Save arukoh/9885708 to your computer and use it in GitHub Desktop.
指定ELBに関連付くインスタンスのec2sshホスト名一覧を表示する。
require "aws-sdk"
REGION = ENV['REGION']
elb = AWS::ELB.new(region: REGION)
ARGV.each do |elb_name|
next if !ARGV.empty? && !ARGV.include?(elb_name)
hosts = []
elb.load_balancers[elb_name].instances.each do |i|
hosts << "#{i.tags["Name"]}.#{REGION}\t#{elb_name}"
end
puts hosts.sort.join("\n")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment