I have used AWS Auto Scaling to set up for my web server. My setting config is 1 for desired, minimum and maximum instances.
Now I want to stop my server, but i may want to restart it in future.
But if I stop directly in EC2 dashboard, it will respawn another EC2 instance, due to AWS Auto Scaling config.
So can I stop my server by setting 0 for desired, minimum and maximum instances ?
I know setting desired instance as 0 will terminate my current instance now, but in this case, if I change desired instance to 1 in future(it will initialize a new instance), can new instance will be initialized with last state when terminated, or it will be initialized with state of setting AMI ?
2
Answers
Yes you can set those the
min
,max
anddesiredCount
values to 0 to stop all running instances under an auto-scaling group. However, any state that you have in the EBS volumes of those severs would be lost, same for the contents of the RAM. If this is fine by you, then please go ahead.If there are important data/state in the RAM and in the EBS volumes that you’d like to keep, please do persists them somewhere more resilient (Like EFS, S3, Redis/Memcache or a DB server).
If you want to resume the operation of those server, you can just restore the three configurations back to 1 or any combination you prefer to spawn instances on-demand.
If your auto scaler is set up through Elastic Beanstalk, then you can scale your instances down to 0 through the configuration:
At the specified time, your instances will be scaled down to 0. Go through similar steps to scale your instances back up.