lib/capistrano/asg/rolling/autoscale_group.rb in capistrano-asg-rolling-0.1.0 vs lib/capistrano/asg/rolling/autoscale_group.rb in capistrano-asg-rolling-0.2.0
- old
+ new
@@ -26,11 +26,11 @@
def launch_template
@launch_template ||= begin
template = aws_autoscaling_group.launch_template
raise Capistrano::ASG::Rolling::NoLaunchTemplate if template.nil?
- LaunchTemplate.new(template.launch_template_id, template.version)
+ LaunchTemplate.new(template.launch_template_id, template.version, template.launch_template_name)
end
end
def subnet_ids
aws_autoscaling_group.vpc_zone_identifier.split(',')
@@ -38,18 +38,27 @@
def instance_warmup_time
aws_autoscaling_group.health_check_grace_period
end
- def start_instance_refresh
+ def start_instance_refresh(launch_template)
aws_autoscaling_client.start_instance_refresh(
auto_scaling_group_name: name,
strategy: 'Rolling',
+ desired_configuration: {
+ launch_template: {
+ launch_template_id: launch_template.id,
+ version: launch_template.version
+ }
+ },
preferences: {
instance_warmup: instance_warmup_time,
- min_healthy_percentage: 100
+ min_healthy_percentage: 100,
+ skip_matching: true
}
)
+ rescue Aws::AutoScaling::Errors::InstanceRefreshInProgress => e
+ raise Capistrano::ASG::Rolling::InstanceRefreshFailed, e
end
# Returns instances with lifecycle state "InService" for this Auto Scaling Group.
def instances
instance_ids = aws_autoscaling_group.instances.select { |i| i.lifecycle_state == LIFECYCLE_STATE_IN_SERVICE }.map(&:instance_id)