There is no straightforward way to pause an Elastic Beanstalk(EB) environment on AWS console. You can’t terminate it as it will be deleted.
Fret not, you can stop your Elastic Beanstalk environment from running when it is not needed so that you only pay when you use it.
AWS Elastic Beanstalk
In case you aren’t familiar with AWS Elastic Beanstalk. On AWS Elastic Beanstalk doc, it says that
With Elastic Beanstalk, you can quickly deploy and manage applications in the AWS Cloud without having to learn about the infrastructure that runs those applications. Elastic Beanstalk reduces management complexity without restricting choice or control. You simply upload your application, and Elastic Beanstalk automatically handles the details of capacity provisioning, load balancing, scaling, and application health monitoring.
For an example use case, you can host your Angular, React or Vue app or your website and manage your hosting via AWS Elastic Beanstalk.
There is no pause action on AWS Elastic Beanstalk console menu:
Use Time-based Scaling
You can modify your EB environment capacity on AWS console. Using time-based scaling, you can schedule a task to turn your EB environment to have 0 instances running and thus pausing your environment.
Steps to pause an EB environment
- On AWS Elastic Beanstalk console, select the
environmentyou want to pause.
- On left panel, select
- On Configuration Overview menu, modify
Capacity(first row, third from right).
On Modify Capacity menu, scroll down to
Add scheduled actionand you will see a menu like this:
- Set the Min and Max of instances and Desired capacity to 0.
- Set the start time about 5 minutes from your current
UTCtime so that the pause action has enough time to execute.
Note that it is in UTC(Coordinated Universal Time).
Addto close the action menu.
Localfor time zone and check if scaling is scheduled at the right time.
Applyso that this added scheduled action will take effect.
- Your environment will be updated and will be set to 0 instance.
Environment Overview page will look like this:
Steps to resume an EB environment
Now that you have your EB environment paused, when you want your EB instance to resume running, you can repeat the steps above but this time, you should set min, max of instances and desired capacity to the number that you would like it to be.
Your scheduled actions are saved in time-based scaling action list. Thus, subsequently, you just need to reschedule the needed action.
Using Elastic Beanstalk CLI
You can use
eb scale to scale your environment to run on a specified number of instances. To pause your environment, you will have to scale it 0.
eb scale Syntax:
eb scale number-of-instances eb scale number-of-instances environment-name
This would work if you are using a load-balancing environment. If you are a using a single instance type of environment, you will see the following message when you use
eb scale 0 myEnvName. If that is the case, you will have to modify your environment to use a load-balancing environment before you can use
eb scale 0 myEnvName.
eb scale 0 myEnvName The environment is currently a single-instance. Do you want to change to a load-balancing environment? WARNING: If you choose yes, the environment and your application will be temporarily unavailable. (Y/n):
With this, you can pause and continue running your Elastic Beanstalk environment whenever you want.
Check out Elastic Beanstalk Worker Auto Scaling By Queue Size if you would like to know how to auto scale an Elastic Beanstalk worker by queue size.
Thank you for reading! Support Jun
If you are preparing for Software Engineer interviews, I suggest Elements of Programming Interviews in Java for algorithm practice. Good luck!
Feel free to contact me if you have any questions.