module AWS::AutoScaling::GroupOptions

This mixin provides a method for parsing Auto Scaling group options (for create and upate methods). @private

Protected Instance Methods

az_opt(options) click to toggle source
# File lib/aws/auto_scaling/group_options.rb, line 117
def az_opt options
  zones = options[:availability_zones]
  zones.map {|zone| zone.is_a?(EC2::AvailabilityZone) ? zone.name : zone }
end
group_options(options) click to toggle source

@param [Hash] options

@option options [required,Integer] :min_size

The maximum size of the Auto Scaling group.

@option options [required,Integer] :max_size

The minimum size of the Auto Scaling group.

@option options [required,LaunchConfiguration,String] :launch_configuration

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

@option options [required,Array<String>] :availability_zones

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

@option options [Integer] :default_cooldown

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

@option options [Integer] :desired_capacity

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

@option options [Integer] :health_check_grace_period

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

@option options [Symbol] :health_check_type

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

@option options [String] :placement_group

Physical location of your cluster placement group created in 
Amazon EC2. For more information about cluster placement group, see
{Using Cluster Instances}[http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/using_cluster_computing.html].

@option options [Array<Hash>] :tags 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.

@option options [Array<EC2::Subnet>,Array<String>] :subnets

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

@return [Hash]

# File lib/aws/auto_scaling/group_options.rb, line 79
def group_options options

  group_opts = {}

  group_opts[:launch_configuration_name] = launch_config_opt(options) if
    options.key?(:launch_configuration)

  group_opts[:availability_zones] = az_opt(options) if
    options.key?(:availability_zones)

  group_opts[:vpc_zone_identifier] = subnets_opt(options) if
    options.key?(:subnets)

  group_opts[:health_check_type] = health_check_type_opt(options) if
    options.key?(:health_check_type)

  group_opts[:tags] = tags_opt(options) if
    options.key?(:tags)

  [ 
    :min_size,
    :max_size,
    :default_cooldown, 
    :desired_capacity, 
    :health_check_grace_period,
    :placement_group,
  ].each do |opt|
    group_opts[opt] = options[opt] if options.key?(opt)
  end

  group_opts
end
health_check_type_opt(options) click to toggle source
# File lib/aws/auto_scaling/group_options.rb, line 134
def health_check_type_opt options
  options[:health_check_type].to_s.upcase
end
launch_config_opt(options) click to toggle source
# File lib/aws/auto_scaling/group_options.rb, line 112
def launch_config_opt options
  lc = options[:launch_configuration]
  lc.is_a?(LaunchConfiguration) ? lc.name : lc
end
load_balancers_opt(options) click to toggle source
# File lib/aws/auto_scaling/group_options.rb, line 122
def load_balancers_opt options
  options[:load_balancers].collect do |lb|
    lb.is_a?(ELB::LoadBalancer) ? lb.name : lb
  end
end
subnets_opt(options) click to toggle source
# File lib/aws/auto_scaling/group_options.rb, line 128
def subnets_opt options
  options[:subnets].collect do |subnet|
    subnet.is_a?(EC2::Subnet) ? subnet.id : subnet
  end.join(',')
end
tags_opt(options) click to toggle source
# File lib/aws/auto_scaling/group_options.rb, line 138
def tags_opt options
  options[:tags].map(&:to_hash).each do |tag|
    tag[:propagate_at_launch] = true unless tag.key?(:propagate_at_launch)
  end
end