Bobcares

wesupport

CLIENT AREACall Us 1-800-383-5193
Bobcares

wesupport

Call Us 1-800-383-5193
Bobcares

wesupport

Call Us 1-800-383-5193

Need help?

Our experts have had an average response time of 13.52 minutes in October 2021 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

EC2 Control instance termination during Auto Scaling

by | Jul 10, 2021

Wondering about EC2 Control instance termination during Auto Scaling? Let us discuss.

Here, at Bobcares, we assist our customers with several AWS queries as part of our AWS Support Services.

Today, let us discuss EC2 Control instance termination.

 

EC2 Control instance termination during Auto Scaling

With the Auto Scaling group, we can control when it adds instances or removes instances from the network architecture.

Manually, we can adjust the desired capacity to scale the size of the group. Or, we can automate the process through scheduled scaling or a scaling policy.

 

Customize the termination policy

Moving ahead, let us see the steps our Support Techs employ to customize the termination policy.

Via console:

  1. Initially, we need to open the Amazon EC2 Auto Scaling console.
  2. Then we select the check box next to the Auto Scaling group, it will open a split-pane with information about the group we select.
  3. On the Details tab, we choose Advanced configurations >> Edit.
  4. For Termination policies, we can choose one or more termination policies.
    In case we select multiple policies, we list them in the order they should apply. If we use the Default policy, we make it the last one on the list.
  5. Finally, we select Update.

Via AWS CLI:

Here, we can use one of the following commands:

  • create-auto-scaling-group
  • update-auto-scaling-group

We can use them either individually or combine them into a list of policies.

For example, we use the command below to update an Auto Scaling group to use the OldestLaunchConfiguration policy first and then use the ClosestToNextInstanceHour policy.

aws autoscaling update-auto-scaling-group --auto-scaling-group-name my-asg --termination-policies "OldestLaunchConfiguration" "ClosestToNextInstanceHour"

Make sure that for the Default termination policy, make it the last one.

For example,

 --termination-policies "OldestLaunchConfiguration" "Default".

 

Enable instance scale-in protection for a group

We can enable instance scale-in protection when we create an Auto Scaling group. By default, instance scale-in protection is disabled.

Via console:

We go to the Configure Group Size and Scaling Policies page, under Instance Scale-in Protection, we select Enable Instance scale-in Protection.

Via AWS CLI: 

To enable instance scale-in protection, we use the following command:

aws autoscaling create-auto-scaling-group --auto-scaling-group-name my-asg --new-instances-protected-from-scale-in ...

 

Modify the instance scale-in protection setting for a group

When we enable the instance scale-in protection, all new instances we launch after it will have instance scale-in protection enabled.

However, the instances before that are not protected from scale-in unless we enable it for each instance individually.

Via console:

  1. Firstly, we open the Amazon EC2 Auto Scaling console.
  2. We select the check box next to the Auto Scaling group, which will then give us information about the group we select.
  3. Then we go to the Details tab >> Advanced configurations >> Edit.
  4. In the Instance scale-in protection, we select Enable instance scale-in protection.
  5. After that, we select Update.

Via AWS CLI:

To enable instance scale-in protection for the specified Auto Scaling group, we run:

aws autoscaling update-auto-scaling-group --auto-scaling-group-name my-asg --new-instances-protected-from-scale-in

On the other hand, to disable instance scale-in protection for the specified group, we run:

aws autoscaling update-auto-scaling-group --auto-scaling-group-name my-asg --no-new-instances-protected-from-scale-in

 

Modify the instance scale-in protection setting for an instance

By default, an instance gets its instance scale-in protection setting from its Auto Scaling group.

However, we can enable or disable this protection for an instance at any time.

Via console:

  1. We open the Amazon EC2 Auto Scaling console.
  2. Here, we select the check box next to the Auto Scaling group.
  3. On the Instance management >> Instances, we select an instance.
  4. To enable, we select Actions >> Set scale-in protection. When prompted, we choose Set scale-in protection.
  5. To disable, we select Actions >> Remove scale-in protection. When prompted, we select Remove scale-in protection.

Via AWS CLI:

To enable instance scale-in protection for an instance, we use:

aws autoscaling set-instance-protection --instance-ids i-5f2e8a0d --auto-scaling-group-name my-asg --protected-from-scale-in

Then to disable instance scale-in protection for an instance, we use:

aws autoscaling set-instance-protection --instance-ids i-5f2e8a0d --auto-scaling-group-name my-asg --no-protected-from-scale-in

[Need help with the procedures? We are here for you]

 

Conclusion

In short, we saw how our Support Techs go about EC2 Control instance termination.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *