Skip to content

Instantly share code, notes, and snippets.

@mkamakura
Created November 18, 2014 10:22
Show Gist options
  • Save mkamakura/d749cf994786e6f2e5fd to your computer and use it in GitHub Desktop.
Save mkamakura/d749cf994786e6f2e5fd to your computer and use it in GitHub Desktop.
ELB配下のプライベートIPアドレスを取得する
AWS.config({
:access_key_id => '<アクセスキー>',
:secret_access_key => '<シークレットキー>',
:ec2_endpoint => 'ec2.ap-northeast-1.amazonaws.com',
:elb_endpoint =>'elasticloadbalancing.ap-northeast-1.amazonaws.com'
})
elb = AWS::ELB.new.load_balancers['<ELB名>']
instances = elb.instances.select {|i| i.exists? && i.status == :running}.map(&:private_ip_address)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment