Class: InstanceSelector::Providers::AWS

Inherits:
AbstractProvider show all
Defined in:
lib/instance_selector/providers/aws.rb

Overview

AWS Provider

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ AWS

Returns a new instance of AWS.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/instance_selector/providers/aws.rb', line 5

def initialize(options = {})
  @fog = options.delete(:fog_client)

  unless @fog
    @options = {
      region: 'us-east-1'
    }.merge(options)

    connect
  end
end

Instance Method Details

#instances(args = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/instance_selector/providers/aws.rb', line 17

def instances(args = {})
  expect_count = args.delete(:expect_count)
  filters = args_to_filters(args)
  instances = on_demand_instances(filters).merge(spot_instances(filters))

  if expect_count && expect_count != instances.size
    raise UnexpectedInstanceCount, "Expected #{expect_count}, got #{instances.size}"
  end

  instances
end