Class: Capistrano::DSL::Ec2::Minimal::Instances

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/capistrano/ec2/minimal.rb

Instance Method Summary collapse

Constructor Details

#initializeInstances

Returns a new instance of Instances.



11
12
13
14
15
16
17
18
19
# File 'lib/capistrano/ec2/minimal.rb', line 11

def initialize
  ec2 = Aws::EC2::Client.new
  filters = [
    { name: 'tag:Project', values: [fetch(:application)] },
    { name: 'tag:Stage', values: [fetch(:stage)] },
    { name: 'instance-state-name', values: %w(running) },
  ]
  @reservations = ec2.describe_instances(filters: filters).reservations
end

Instance Method Details

#eachObject



21
22
23
24
25
26
27
# File 'lib/capistrano/ec2/minimal.rb', line 21

def each
  @reservations.each do |reservation|
    reservation.instances.each do |instance|
      yield(instance)
    end
  end
end