4

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.

alextc
  • 3,206
  • 10
  • 63
  • 107

1 Answers1

7

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.

Matt Houser
  • 33,983
  • 6
  • 70
  • 88
  • Thanks @Matt. With your solution, if the instance is terminated by setting min=desired=0 does it automatically get removed in a couple of hours like any other manually terminated instances? If that is the case how can I re-set min=desired=1 on the instance that is already gone? If not, does it just remain terminated and stay there? – alextc Mar 11 '16 at 01:27
  • Yes. Once terminated, the instance will disappear after 1 hour. You reset `min=desired=1` on your Auto Scaling group, not on the instance. Once done, a fresh EC2 instance will be created. – Matt Houser Mar 11 '16 at 01:29