1

I'm updating our production ASG at night to use small type of instances. For example, using m5 type instances in business hours, and using t3 type instances at night.

For this, I update the launch template version and desired capacity of the ASG by lambda with cloudWatch.

When it update the launch template version and desired capacity, it start a new instance depends on the new version of template well. But the problem is, sometimes ASG stop the new instance instead of the old one (old version type)

So I'm planning to update the minSize of the ASG also and change it again after sometimes to wait the new version instance be started well.

For example, update the minSize and desired capacity as 2 and wait to start the new type instance by updated version launch template. And after sometimes, update the minSize and desired capacity as 1 to stop the old type instance.

Is this right way? or Could you advice me better way?

Thanks.

Noah Gray
  • 151
  • 1
  • 1
  • 13
  • Are you using [instance-refresh](https://docs.aws.amazon.com/cli/latest/reference/autoscaling/start-instance-refresh.html) for asg or deploying through CloudFormation? – Marcin Jan 18 '21 at 08:24
  • I didn't know the 'instance-refresh' before. Will check it! I copy the launch configuration to launch template and add a version with different instance type. And change the launch template version with lambda and cloudwatch... We are trying to deploy with terraform but it is not yet completed... – Noah Gray Jan 19 '21 at 00:12
  • `instance-refresh` has option to specify `MinHealthyPercentage`. If you set it to 100, no existing instances should be terminated from what I understand. Please let me know how it will go. Curious of your test results. – Marcin Jan 19 '21 at 00:38

1 Answers1

0

The solution is to set termination policy setting in the autoscaling group to OldestInstance.

This way, ASG will first terminate the oldest instances, which are the instances that you want to get rid of.

GoodMirek
  • 215
  • 1
  • 10