Class: Awshark::Ec2::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/awshark/ec2/manager.rb

Instance Method Summary collapse

Instance Method Details

#all_instancesObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/awshark/ec2/manager.rb', line 6

def all_instances
  return @all_instances if defined?(@all_instances)

  @all_instances = []
  response = client.describe_instances

  response.each_page do |page|
    page.reservations.each do |reservation|
      reservation.instances.each do |instance|
        @all_instances << Instance.new(instance)
      end
    end
  end

  @all_instances
end