LoginSignup
3
2

More than 5 years have passed since last update.

elastic beanstalk環境にあるインスタンスのprivate ipをリストで取得する

Posted at

ruby

env = JSON.parse(`aws elasticbeanstalk describe-environment-resources --environment-name hogehoge`)
instance_ids = env['EnvironmentResources']['Instances'].map {|instance| instance['Id']}
reservations = JSON.parse(`aws ec2 describe-instances --instance-ids #{instance_ids.join(' ')}`)
private_ips = reservations['Reservations'].flat_map{|reservation| reservation['Instances']}.map{|instance| instance['PrivateIpAddress']}
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2