Module: Aws::AutoScaling::AutoScalingGroupFletsExtension

Defined in:
lib/aws-sdk-autoscaling/fleets.rb

Instance Method Summary collapse

Instance Method Details

#fleetObject



21
22
23
24
25
26
27
# File 'lib/aws-sdk-autoscaling/fleets.rb', line 21

def fleet
  fleet_tag = tags.find {|t| t.key =~ /^asgfleet:/ }
  return nil unless fleet_tag

  fleet_name = fleet_tag.key.split(':', 2)[1]
  Fleet.new(fleet_name, client: @client)
end

#set_fleet(fleet, role = "member") ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/aws-sdk-autoscaling/fleets.rb', line 29

def set_fleet fleet, role = "member"
  if fleet && self.fleet
    raise ArgumentError, "Group already belongs to a fleet"
  end

  if fleet.nil?
    tags.find {|t| t.key =~ /^asgfleet:/ }.delete
  else
    @client.create_or_update_tags(:tags => [{
      :resource_type => "auto-scaling-group",
      :resource_id => name,
      :key => "asgfleet:#{fleet.is_a?(Fleet) ? fleet.name : fleet}",
      :value => role,
      :propagate_at_launch => false
    }])
  end
end