3
votes

Newbie to AWS, I have a t2.micro EC2 instance supporting my Elastic Beanstalk application. It was created while I deployed my WAR file to Elastic Beanstalk.

My EB application does not need to run 24 hrs a day so it only needs to work during a specific period of time a day. When I tried to stop it from the AWS EC2 management console by selecting "Actions -> Instance state -> Stop", the instance was terminated instead but a new instance was created and initialized and then running automatically later.

How can I stop an EC2 instance properly to suit my need? Thanks.

1

1 Answers

7
votes

Your EB application is utilizing an Auto Scaling group to ensure your EC2 instance stays running.

When you stop your EC2 instance, Auto Scaling sees that as an unhealthy instance and terminates it, then replaces it with a new, healthy instance.

You cannot stop EC2 instances that are part of an Auto Scaling group. The best you can do is to edit your Auto Scaling group policy to set min=desired=0. This will terminate the instance and keep it terminated. When you want to get your instance running again, edit your Auto Scaling group and reset min=desired=1.