class Topo::Provision::AwsAutoScalingGroupGenerator

Public Class Methods

from_node(node) click to toggle source
# File lib/topo/provision/aws/generators/aws_auto_scaling_group.rb, line 34
def self.from_node(node)
  auto_scaling = value_from_path(node, %w[provisioning  node_group  auto_scaling]) || {}
      
  group_data = { 
    "name" => auto_scaling['group_name'] ||  node['name'] + "_group",
    "launch_configuration" => auto_scaling['launch_configuration'] ||  node['name'] + "_config"
  }

  %w[max_size min_size desired_capacity availability_zones load_balancers].each do |key|
    group_data[key] = auto_scaling[key] if auto_scaling.key? key
  end 
        
  options = auto_scaling['group_options']
  if options
     # we also need to convert some of the field values in options, and then all of the keys
     %w[health_check_type].each do |key|
       options[key] = options[key].to_sym if options.key? key
     end
     group_data['options'] = convert_keys_to_sym_deep(options)
  end    
  
  self.new(group_data)
 end
new(data) click to toggle source
Calls superclass method Topo::Provision::ResourceGenerator::new
# File lib/topo/provision/aws/generators/aws_auto_scaling_group.rb, line 26
def initialize(data)
  @resource_type ||= "aws_auto_scaling_group"
  super
  %w[launch_configuration max_size min_size desired_capacity availability_zones load_balancers options].each do |key|
    @resource_attributes[key] = data[key] if data.key? key
  end       
end