lib/aerosol/auto_scaling.rb in aerosol-1.9.1 vs lib/aerosol/auto_scaling.rb in aerosol-1.9.2
- old
+ new
@@ -5,11 +5,16 @@
logger_prefix '[aerosol auto_scaling]'
aws_attribute :auto_scaling_group_name, :availability_zones, :min_size, :max_size, :default_cooldown,
:desired_capacity, :health_check_grace_period, :health_check_type, :load_balancer_names,
:placement_group, :tags, :created_time, :vpc_zone_identifier, :target_group_arns
aws_class_attribute :launch_configuration, Aerosol::LaunchConfiguration
- aws_class_attribute :launch_template, Aerosol::LaunchTemplate
+ aws_class_attribute(
+ :launch_template,
+ Aerosol::LaunchTemplate,
+ proc { |argument| argument.fetch(:launch_template, {})[:launch_template_name] }
+ )
+
primary_key :auto_scaling_group_name
def initialize(options={}, &block)
tag = options.delete(:tag)
super(options, &block)
@@ -86,11 +91,11 @@
end
def all_instances
conn.describe_auto_scaling_groups(auto_scaling_group_names: [*auto_scaling_group_name])
.auto_scaling_groups.first
- .instances.map { |instance| Aerosol::Instance.from_hash(instance) }
+ .instances.map { |instance| Aerosol::Instance.from_hash(instance.to_hash) }
end
def launch_details
launch_configuration || launch_template
end
@@ -152,15 +157,9 @@
"placement_group" => "#{placement_group}", \
"tags" => #{tags.to_s}, \
"created_time" => "#{created_time}" \
"target_group_arns" => "#{target_group_arns}" \
}}
- end
-
- def self.from_hash(hash)
- instance = super(hash)
- instance['launch_template'] = (hash[:launch_template][:launch_template_name]) if hash[:launch_template]
- instance
end
private
def conn
Aerosol::AWS.auto_scaling