Category: Kubernetes, automation

AWS Elastic Beanstalk handles provisioning resources, maintenance, health checks, automatic scaling, and other common tasks necessary to keep your application running, which allows you to focus on your application code. You can now run your applications on Elastic Beanstalk using Amazon Elastic Compute Cloud (Amazon EC2).

Spot Instances are available at up to a 90% discount compared to On-Demand prices, which are also available for other deployment services like Amazon Elastic Container Service (Amazon ECS) and Amazon Elastic Kubernetes Service (Amazon EKS).

To convert from load balanced to single instance, enter the following code: To convert from single instance to load balanced, enter the following code: You can then configure cron jobs for these commands at the required times: When you have many resources in Elastic Beanstalk environments and want to the optimize the cost during low-traffic times or after work hours while keeping the environment running, a good approach is to set the number of instances to (0 or 1) or any minimal number of instances for all test environments.

You can automate this approach for a number of Elastic Beanstalk environments using the following sample bash script: You can configure a cron job to run this script on a daily basis as per the following example code: When you want to stop all your testing environments overnight, you can terminate Elastic Beanstalk environments after work times and restore them again in the morning.

Related Articles