Sha256: 4a92a470fe75654672f3aa161f69efa4bb1525faa77fdf612e63a3ab7e30cfcf

Contents?: true

Size: 804 Bytes

Versions: 2

Compression:

Stored size: 804 Bytes

Contents

module Hashicorptools
  class UpdateLaunchConfiguration < Thor
    desc 'deploy ASG_NAME', 'recycle instances in the ASG with no downtime'
    def deploy(asg_name)
      asg = AutoScalingGroup.new(name: asg_name)
      if asg.group.nil?
        raise "could not find asg #{asg_name}"
      end
      current_count = asg.group.instances.size || 1

      if asg.group.max_size < (current_count * 2)
        raise "max size must be more than twice current count to deploy a new AMI"
      else
        # first doulbe the instance count to get new launch config live.
        asg.set_desired_instances(current_count * 2)

        # then bring the instance count back down again.
        asg.set_desired_instances(current_count)

        asg.verify_all_instances_using_correct_ami
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hashicorptools-0.2.3 lib/hashicorptools/update_launch_configuration.rb
hashicorptools-0.2.2 lib/hashicorptools/update_launch_configuration.rb