Class: Hashicorptools::UpdateLaunchConfiguration

Inherits:
Thor
  • Object
show all
Defined in:
lib/hashicorptools/update_launch_configuration.rb

Instance Method Summary collapse

Instance Method Details

#deploy(asg_name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/hashicorptools/update_launch_configuration.rb', line 5

def deploy(asg_name)
  asg = AutoScalingGroup.new(name: asg_name, region: options[:aws_region])
  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