Stop and Start Elastic Beanstalk Services

雨燕双飞 提交于 2019-12-01 02:24:42

The EB command line interface has an eb stop command. Here is a little bit about what the command actually does:

The eb stop command deletes the AWS resources that are running your application (such as the ELB and the EC2 instances). It however leaves behind all of the application versions and configuration settings that you had deployed, so you can quickly get started again. Eb stop is ideal when you are developing and testing your application and don’t need the AWS resources running over night. You can get going again by simply running eb start.

EDIT:

As stated in the below comment, this is no longer a command in the new eb-cli.

If you have a load-balanced environment you can try the following trick

$ aws autoscaling update-auto-scaling-group \
--auto-scaling-group-name my-auto-scaling-group \
--min-size 0 --max-size 0 --desired-capacity 0

It will remove all instances from the environment but won't delete the environment itself. Unfortunately you still will pay for elastic load balancer. But usually EC2 is the most "heavy" part.

Does it work for 0?

yes, it does

$ aws autoscaling describe-auto-scaling-groups --region us-east-1 \
--auto-scaling-group-name ASG_NAME \
--query "AutoScalingGroups[].{DesiredCapacity:DesiredCapacity,MinSize:MinSize,MaxSize:MaxSize}"

[
    {
        "MinSize": 2, 
        "MaxSize": 2, 
        "DesiredCapacity": 2
    }
]

$ aws autoscaling update-auto-scaling-group --region us-east-1 \
--auto-scaling-group-name ASG_NAME \
--min-size 0 --max-size 0 --desired-capacity 0

$ aws autoscaling describe-auto-scaling-groups --region us-east-1 \
--auto-scaling-group-name ASG_NAME \
--query "AutoScalingGroups[].{DesiredCapacity:DesiredCapacity,MinSize:MinSize,MaxSize:MaxSize}"

[
    {
        "MinSize": 0, 
        "MaxSize": 0, 
        "DesiredCapacity": 0
    }
]

And then you can check environment status

$ eb status -v
Environment details for: test
  Application name: TEST
  Region: us-east-1
  Deployed Version: app-170925_181953
  Environment ID: e-1234567890
  Platform: arn:aws:elasticbeanstalk:us-east-1::platform/Multi-container Docker running on 64bit Amazon Linux/2.7.4
  Tier: WebServer-Standard
  CNAME: test.us-east-1.elasticbeanstalk.com
  Updated: 2017-09-25 15:23:22.980000+00:00
  Status: Ready
  Health: Grey
  Running instances: 0

In the beanstalk webconsole you will see the following message

INFO Environment health has transitioned from Ok to No Data. 
There are no instances. Auto Scaling group desired capacity is set to zero.

eb stop is deprecated. I also had the same problem and the only solution I could come up with was to backup the environment and then restore it.

Here's a blog post in which I'm explaining it: http://pminkov.github.io/blog/how-to-shut-down-and-restore-an-elastic-beanstalk-environment.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!