0
votes

I have created a custom AMI wherein a service xxx is started when aws instance gets started and service xxx gets stopped when that aws instance gets stopped. I have wrapped that ami under CloudFormation's AWS::AutoScaling::AutoScalingGroup. When a new instance gets added using auto scaling group the xxx service too gets started on it. But when I reduce the number of desired instances the xxx does not get stopped.

So reducing desired numInstances in autoscaling group simply terminates the instance without stopping it?

How do I get the notification to stop the xxx service before instance termination?

1

1 Answers

0
votes

Yes, when Auto Scaling scales down/in, it terminates instances (it does not simply stop them).

To react to such an event, you can use Lifecycle Hooks which allow you to perform custom actions as Auto Scaling launches or terminates instances.