Reputation: 47921
I want to shut down the app servers while I upgrade the database.
Is there a way to pause or stop the app servers without terminating/destroying the environment?
Can I just go to the Elastic Beanstalk load balancer and change that temporarily without any issues or consequences to the Elastic Beanstalk configurations or the way it manages its servers?
Upvotes: 86
Views: 37896
Reputation: 2588
I could only make this work using the aws-cli
by setting the ASG values directly. Scale up to 1 instance:
aws autoscaling update-auto-scaling-group --auto-scaling-group-name <ASG-Name>
--min-size=1 --max-size=1 --region <region>
Then to pause, reduce the min size in the ASG to 0:
aws autoscaling update-auto-scaling-group --auto-scaling-group-name <ASG-Name>
--min-size=0 --max-size=1 --region <region>`
Then set the desired capacity to 0 to kill the instance:
aws autoscaling set-desired-capacity --auto-scaling-group-name <ASG-Name>
--desired-capacity 0 --region <region>
Upvotes: 1
Reputation: 3328
Setting min
and max
to 0
under Configuration > Capacity > Auto Scaling Group
will shutdown the EC2 instance.
Event entry:
There are no instances. Auto Scaling group desired capacity is set to zero.
Upvotes: 6
Reputation: 9930
This is the only method that worked for me.
1) Go to the environment you want to pause on AWS Management Console
2) Select "Configuration"
3) Open "Capacity"
4) Scroll all the way down to "Time-based Scaling"
5) Click the "Add schedule action" button
6) Set the action to few minutes in the future (recommended: 5 minutes so environment has time to reset), give it a name (for example "terminate") and set minimum and maximum instances to '0':
Note that times are set in UTC. You can use time.is/UTC to determine the current UTC.
This would create an error that would shut down your environment so you won't have to pay for it. Any other methods suggested just create a error at time of applying so it doesn't pass through and environment would still work.
To re-enable the environment, just schedule another action with instance min 1 and max 4 for example (those are the defaults).
Upvotes: 105
Reputation: 4312
From AWS What's New blog Dec 16, 2016:
You can now restore AWS Elastic Beanstalk environments that have been terminated. You can restore Elastic Beanstalk environments within 42 days of their termination, and the restored environments will retain the original environment IDs, CNAMEs, application versions, and configuration options.
You can use the Elastic Beanstalk console, EB CLI, AWS CLI, SDK, and API to restore environments that have been terminated. Visit the documentation to learn more.
Upvotes: 20
Reputation: 64761
Depending on how you orchestrate your AWS Elastic Beanstalk environment, this can be achieved with the EB Command Line Interface's eb scale command for example:
Scales the environment to always run on a specified number of instances, setting both the minimum and maximum number of instances to the specified number.
Alternatively you can always manually scale down the auto scaling group yourself by setting the minimum and desired number of instances to zero.
Auto Scaling Groups
), the AWS Command Line Interface (the autoscaling reference features resp. commands), or also programmatically via the AWS SDKs, in case you want to include it into your deployment automation.Upvotes: 14