Elasticbeanstalk scale-in protection

0

I am using elastic beanstalk for my project. I want one of my instances to not be deleted at all. Previously using "Set scale-in protection" used to work, but nowadays, it's deleting the instance even if I set the scale-in protection. Is there any other way to achieve this?

asked 20 days ago34 views
2 Answers
0

While scale-in protection is typically used to prevent instances from being terminated during scale-in events, it's important to note that this protection has limitations and may not provide absolute guarantees in all scenarios.

For your specific use case with Elastic Beanstalk, where you want to ensure that one particular instance is never deleted, there are a few approaches you can consider:

  1. Instance Scale-in Protection: Double-check that you have correctly enabled instance scale-in protection for the specific instance you want to protect. This can be done through the EC2 Auto Scaling group associated with your Elastic Beanstalk environment. Ensure that the protection is applied at the individual instance level, not just at the Auto Scaling group level.

  2. Custom Termination Policy: You can implement a custom termination policy using a Lambda function. This allows you to have more fine-grained control over which instances are terminated first during scale-in events. You could configure the policy to always exclude your critical instance from termination.

  3. Separate Auto Scaling Group: Consider creating a separate Auto Scaling group for your critical instance, with a minimum and maximum capacity of 1. This isolates it from the scaling activities of other instances.

  4. Task Protection (for containerized workloads): If you're running containerized workloads, you might be able to use task protection features. For example, Amazon ECS (which can be used with Elastic Beanstalk) offers task scale-in protection that can prevent specific tasks from being terminated.

  5. Manual Management: As a last resort, you could manage this critical instance manually outside of Elastic Beanstalk's Auto Scaling mechanisms. However, this approach would require more hands-on management and may not align well with Elastic Beanstalk's automated lifecycle.

It's important to note that while these methods can significantly reduce the likelihood of your instance being terminated, they may not provide absolute protection in all scenarios. Instances may still be terminated due to health check failures, manual termination, or other exceptional circumstances.

Additionally, remember that protecting an instance indefinitely from termination may interfere with important processes like updating and patching. Consider implementing a strategy that allows for occasional controlled replacement of even your critical instances to ensure they remain up-to-date and healthy.
Sources
Use instance scale-in protection to control instance termination - Amazon EC2 Auto Scaling
Design your applications to gracefully handle instance termination - Amazon EC2 Auto Scaling
Protect your Amazon ECS tasks from being terminated by scale-in events - Amazon Elastic Container Service

profile picture
answered 20 days ago
0

scale-in protection only protects from graceful scale-in events (ie, a scaling policy lowering the Desired)

It does NOT protect from explicit termination requests (ie, rolling updates), or unhealthy instance replacements

If you have a 'special' instance that can't be terminated, it should not be in an ASG (which means it shouldn't be in Beanstalk). You'll either want to find a way to remove the need for this instance being special, or run it as a standalone EC2 instance

AWS
EXPERT
answered 17 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions