How to stop elastic beanstalk without terminating?

Solution 1:

Currently, there's no easy way to suspend an environment. There's also no easy way to have a maintenance page for your environment while your instances are down.

When you set the number of instances to 0, the instances will terminate but you'll have to do this all manually as the EB console does not allow an entry of 0. You can do this by running this:

as-update-auto-scaling-group YourAutoScalingGroupID --min-size 0 --max-size 0 --desired-capacity 0

This, however, only terminates your instances. Everything else is still running, like your ELB. You can then change it back to your previous settings when you're done.

Solution 2:

An Amazon Customer found a simple way to do this with single instance environments.

You can keep an elastic beanstalk environment setup 24/7, and stop only the associated EC2 instance to save money.

To set it up, go to your EC2 console, click Auto Scaling Groups (a group is set up for single instance environments, despite the absence of an ELB). Click your group (check the tags tab to find the right one). Under the details tab, click "edit" and update "Min" to be 0. Now go to the Instances tab and set the instance here to Standby.

You can now toggle your EC2 instance on/off whenever you like using the EC2 Instances console, and elastic beanstalk won't freak out and terminate/re-create anything. You don't even have to put the instance back InService, it will begin to serve on your elastic beanstalk CNAME as soon as it boots back up.

source (Amazon Customer's comment)

When I tried this solution myself I was not able to find Suspend action. Currently, there're only Stop and Terminate actions at Instances tab. And when you choose any, AWS warns you that any data saved to ephemeral storage will be lost.