Class: AWS::AutoScaling::GroupCollection

Inherits:
Object
  • Object
show all
Includes:
GroupOptions, Core::Collection::Limitable
Defined in:
lib/aws/auto_scaling/group_collection.rb

Instance Attribute Summary

Attributes included from Core::Model

#config

Instance Method Summary collapse

Methods included from Core::Collection::Limitable

#each_batch

Methods included from Core::Collection

#each, #each_batch, #enum, #first, #in_groups_of, #page

Methods included from Core::Model

#client, #config_prefix, #initialize, #inspect

Instance Method Details

#[](name) ⇒ Group

Parameters:

  • name (String)

    The name of the Auto Scaling group.

Returns:



66
67
68
# File 'lib/aws/auto_scaling/group_collection.rb', line 66

def [] name
  Group.new(name, :config => config)
end

#create(name, options = {}) ⇒ Group

Creates an Auto Scaling Group.

group = auto_scaling.groups.create('group-name', 
  :launch_configuration => 'launch-config-name',
  :availability_zones => %(us-east-1a us-east-1b),
  :min_size => 1,
  :max_size => 4)

Parameters:

  • name (String)

    The name of the Auto Scaling group.

    Must be unique within the scope of your AWS account.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :load_balancers (Array<ELB::LoadBalancer>, Array<String>)

    A list of load balancers to use. This can be an array of ELB::LoadBalancer objects or an array of load balancer names.

  • :min_size (required, Integer)

    The maximum size of the Auto Scaling group.

  • :max_size (required, Integer)

    The minimum size of the Auto Scaling group.

  • :launch_configuration (required, LaunchConfiguration, String)

    The launch configuration to use with the Auto Scaling group. This may be a LaunchConfiguration object or a launch configuration name string.

  • :availability_zones (required, Array<String>)

    A list of Availability Zones for the Auto Scaling group. This can be EC2::AvailabilityZone objects or availability zone names.

  • :default_cooldown (Integer)

    The amount of time, in seconds, after a scaling activity completes before any further trigger-related scaling activities can start.

  • :desired_capacity (Integer)

    The number of Amazon EC2 instances that should be running in the group.

  • :health_check_grace_period (Integer)

    Length of time in seconds after a new Amazon EC2 instance comes into service that Auto Scaling starts checking its health.

  • :health_check_type (Symbol)

    The service you want the health status from, Amazon EC2 or Elastic Load Balancer. Valid values are :ec2 or :elb.

  • :placement_group (String)

    Physical location of your cluster placement group created in Amazon EC2. For more information about cluster placement group, see Using Cluster Instances.

  • :tags (Array<Hash>)

    A list of tags to apply launched instances. Each tag hash may have the following keys:

    • :key - (required,String) The tag name.

    • :value - (String) The optional tag value.

    • :propagate_at_launch - (Boolean) Whether or not to propagate to instances, defaults to true.

  • :subnets (Array<EC2::Subnet>, Array<String>)

    A list of subnet identifiers of Amazon Virtual Private Clouds (Amazon VPCs). Ensure the subnets’ Availability Zones match the Availability Zones specified.

Returns:



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/aws/auto_scaling/group_collection.rb', line 43

def create name, options = {}

  unless options[:launch_configuration]
    raise ArgumentError, 'missing required option :launch_configuration'
  end

  group_opts = group_options(options)
  group_opts[:auto_scaling_group_name] = name

  if balancers = options[:load_balancers]
    group_opts[:load_balancer_names] = balancers.collect do |balancer|
      balancer.is_a?(ELB::LoadBalancer) ? balancer.name : balancer
    end
  end

  client.create_auto_scaling_group(group_opts)

  self[name]

end