Class: Capistrano::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/aws/ec2/patches.rb

Overview

Patches the Capistrano Configuration class to add our aws-ec2 features

Constant Summary collapse

EC2_STATE_RUNNING_CODE =
16

Instance Method Summary collapse

Instance Method Details

#ec2_instances(running_only: true, tags: {}) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/capistrano/aws/ec2/patches.rb', line 10

def ec2_instances(running_only: true, tags: {})
  ec2_resource.instances.filter do |instance|
    # Filter out non-running instances
    next false if running_only && instance.state.code != EC2_STATE_RUNNING_CODE

    # Filter out instances not matching the given tags
    tags.all? { |key, value| instance.tags.any? { |tag| tag.key == key && tag.value == value } }
  end
end