1

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.

Aditya Goel
  • 201
  • 1
  • 15
  • i can see that you are using load balancer, so asg automatically instance if it fails health check and relaunches a new instance ( but since max capacity is 1 asg is not doing that). can you check you health checks for your target group associated with load balancer and also health status of those instance under that target group? – Jatin Mehrotra Apr 24 '21 at 09:39
  • Thanks @Jatin for responding. Yes I have a ALB and it has a TG1 target-group associated with it. This Target-group initially had 0 instances. – Aditya Goel Apr 24 '21 at 09:50
  • The issue was with userData of the launch-template.I think, it worked now. My userdata didn;t had ```#!/bin/bash``` in the beginning and hence the issue. – Aditya Goel Apr 24 '21 at 09:51
  • 1
    Hi. I've noticed that you have lots of questions with answers, yet only a single answer was ever accepted. Accepting good answers is not only a good practice, but it also reduces duplicates and makes your questions more likely to be answered. @JatinMehrotra is one of such answers. – Marcin Apr 24 '21 at 10:30

1 Answers1

2

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

Jatin Mehrotra
  • 9,286
  • 4
  • 28
  • 67