Search code examples
amazon-web-servicesamazon-ec2aws-auto-scaling

EC2 instance launched through AutoScaling group drains automatically quickly


We are learning AWS hands-on. We just launched an ASG with min and max capacity of 1. As soon as EC2 instance spins-up, it automatically goes under de-registration & terminates. This process continues to happen. Ec2 instance drains and then new one gets launched and so on.

I already have Protection from Scale-In enabled.

enter image description here

enter image description here

enter image description here

Any help shall be highly appreciated.


Solution

  • based on the comments:-

    asg automatically terminates those instances which fails health checks and automatically replaces them with new instance docs for reference.

    But here since max capacity is also one asg is not able to launch new instance.

    the issue was the OP uses a user data script to launch its webserver or website, however the script misses #!/bin/bash which leads to unsuccessful execution of bash script and eventually the health check by load balancer fails which makes asg terminates the instance