Class: Aws::AutoScaling::FleetCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/aws-sdk-autoscaling/fleet_collection.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ FleetCollection

Returns a new instance of FleetCollection.



6
7
8
# File 'lib/aws-sdk-autoscaling/fleet_collection.rb', line 6

def initialize(opts)
  @resource = opts.delete(:resource)
end

Instance Method Details

#create(name, template_group) ⇒ Fleet

Create an ASG Fleet.

To create a Fleet, you must supply an already-constructed Auto Scaling group to be used as the template for new groups added to the fleet.

fleet = auto_scaling.fleets.create('fleet-name',
    auto_scaling.groups['my-asg-group'])

Parameters:

  • name (String)

    The name of the new fleet to create. Must be unique in your account.

  • group (Group)

    The group to be used as a template for future groups and fleet changes.

Returns:

Raises:

  • (ArgumentError)


27
28
29
30
31
32
33
# File 'lib/aws-sdk-autoscaling/fleet_collection.rb', line 27

def create name, template_group
  raise ArgumentError, "Fleet #{name} already exists" if @resource.fleet(name).exists?
  raise ArgumentError, "Group is already in a fleet" if template_group.fleet

  template_group.set_fleet(name, "template")
  @resource.fleet(name)
end

#eachObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/aws-sdk-autoscaling/fleet_collection.rb', line 35

def each
  yielded_fleets = []

  @resource.tags.each do |tag|
    if tag.key =~ /^asgfleet:/
      name = tag.key.split(':', 2)[1]

      next if yielded_fleets.include? name
      yielded_fleets << name

      yield @resource.fleet(name)
    end
  end
end