Created
September 25, 2014 02:05
-
-
Save srockstyle/8ef23a5134a3eee8d207 to your computer and use it in GitHub Desktop.
AWS-SDK for RubyからELB直下のインスタンスのpublic DNSを一括取得するには ref: http://qiita.com/srockstyle/items/7b72a56bc0ac02953164
This file contains hidden or 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
| #!/usr/bin/ruby | |
| require "aws-sdk" | |
| require "pp" | |
| AWS.config( | |
| access_key_id: '******', | |
| secret_access_key: '******', | |
| ec2_endpoint: '[環境に合わせてください]', | |
| elb_endpoint: '[環境にあわせてください]' | |
| ) | |
| elb = AWS::ELB.new.load_balancers['[自分のELB名]'] | |
| instances = elb.instances.select {|i| i.exists? && i.status == :running}.map(&:dns_name) | |
| pp instances |
This file contains hidden or 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
| [ "ec2-**-***-***-**.ap-southeast-1.compute.amazonaws.com", | |
| "ec2-**-***-***-**.ap-southeast-1.compute.amazonaws.com", | |
| "ec2-**-***-***-**.ap-southeast-1.compute.amazonaws.com", | |
| "ec2-**-***-***-**.ap-southeast-1.compute.amazonaws.com"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment