Getting a list of instances in an EC2 auto scale group?

前端 未结 7 1024
一整个雨季
一整个雨季 2020-12-19 04:13

Is there a utility or script available to retrieve a list of all instances from AWS EC2 auto scale group?

I need a dynamically generated list of production instance

7条回答
  •  无人及你
    2020-12-19 04:51

    for ruby using aws-sdk gem v2 First create ec2 object as this:

    ec2 = Aws::EC2::Resource.new(region: 'region', credentials: Aws::Credentials.new('IAM_KEY', 'IAM_SECRET') )

    instances = []

    ec2.instances.each do |i|
       p "instance id---", i.id
       instances << i.id
    

    end

    This will fetch all instance ids in particular region and can use more filters like ip_address.

提交回复
热议问题