Created
March 31, 2014 05:11
-
-
Save arukoh/9885708 to your computer and use it in GitHub Desktop.
指定ELBに関連付くインスタンスのec2sshホスト名一覧を表示する。
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
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