Stop and Start Elastic Beanstalk Services

后端 未结 3 952
生来不讨喜
生来不讨喜 2021-01-07 21:54

I wanted to know if there is an option to STOP Amazon Elastic Beanstalk as an atomic unit as I can do with EC2 servers instead of going through each service (e.g. load balan

3条回答
  •  一向
    一向 (楼主)
    2021-01-07 22:34

    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.
    

提交回复
热议问题