Reputation: 1341
I have an Autoscaling Group behind an Application Load Balancer. Both of them are configured to use 2 subnets for 2 different AZ.
The Autoscaling Group is set to provision only 1 instance (min:1, max: 1, desired: 1)
Now in case of AZ failure the Load balancer will detect that the instance is Unhealthy and stop sending tarfic to it.
But i assume that the Autoscaling Group will consider the instance as Healthy, so it will not create a new instance in the second AZ.
So my question is there a way to make the Loadbalancer to notify the autoscaling group to terminate the instance in the failed AZ and to start a new one in the ok AZ ?
I now that the best practice is to set the Autoscaling group to provision for example 2 instances, one in each AZ. But is there a way to make it work with only 1 instance ?
Thanks.
Upvotes: 0
Views: 452
Reputation: 238697
ASG has two options for health checks. By default, it uses EC2 health checks. But since you are using ALB, you should set ASG to use ALB health checks (in addition to EC2 health checks).
This way if ALB determines that your instance is unhealthy for whatever reason, ASG will also consider is as unhealthy.
There are also custom health checks, but in your case, using ALB health checks should be sufficient.
More is here: https://docs.aws.amazon.com/autoscaling/ec2/userguide/healthcheck.html
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-recover.html
Upvotes: 2