'Is there a way to configure the Auto Scaling Group termination policy when using Elastic Beanstalk?

The ASG part of Beanstalk options does not have it listed: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-general.html?shortFooter=true#command-options-general-autoscalingasg - and neither does the rest of the page.

Right now I'm having to resort to manually editing the termination policy in the ASG page in EC2.



Solution 1:[1]

The following works for me. I use .ebextensions folder to configure my apps. Inside I have created a termination.config file containing this:

Resources:
      AWSEBAutoScalingGroup:
        Type: "AWS::AutoScaling::AutoScalingGroup"
        Properties:
          TerminationPolicies: [ "OldestInstance" ]
   

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Umang Jain