AWS Ruby SDK filtering

104 views Asked by At

I'm refactoring a Ruby framework that is calling describe_instances and then filtering the response for just the VPC names.

It seems a waste of bandwidth to pull down the data for every instance in the region and then filter out the VPC ids in this way.

When I look at the documentation for filtering server side I see posts doing things like applying filters for all instances of type xx and so on.

What I want to do is pull down all VPC ids as a unique list.

Can anyone point me at an example of how to do that?

Thanks in advance

1

There are 1 answers

0
Kaliklipper On

Never mind, I discovered the describe_vpcs endpoint:

def get_vpc_ids
  ec2_object.describe_vpcs[:vpcs].each do |vpc|
    @vpc_list.push(vpc[:vpc_id])
  end
  @vpc_list.uniq!
end