AWS AutoScaling group のインスタンス一覧を ruby で取得する
require 'aws-sdk-v1'
AWS::config(
access_key_id: 'xxxxxxxxxxxxxxxxxxx',
secret_access_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
region: 'ap-northeast-1',
)
auto_scaling = AWS::AutoScaling.new
instance_ids = auto_scaling.groups['staging_web'].auto_scaling_instances.map(&:instance_id).to_a
response = AWS::EC2::Client.new.describe_instances instance_ids:instance_ids
for reservation in response[:reservation_set]
for instance in reservation[:instances_set]
puts instance[:dns_name]
end
end