Want to delete Auto Scaling infrastructure in EC2? We can help you.
If we delete an Auto Scaling group, it terminates the instances. It also deletes any associated logs or data, and any volumes on the instance.
Here, at Bobcares, we assist our customers with several AWS queries as part of our AWS Support Services.
Today, let us see how we can delete the auto scalling infrastructure.
Delete Auto Scaling infrastructure in EC2
In case we do not want to terminate one or more instances, we can detach them before we delete the Auto Scaling group.
Delete via console:
- Initially, we open the Amazon EC2 Auto Scaling console.
- There, we can see a check box next to the Auto Scaling group, we select it and then select Delete.
- In case of a prompt for confirmation, we select Delete.
- A loading icon in the Name column indicates the deletion.
It will take a few minutes to terminate the instance and delete the group. To see the current state, we can refresh the list.
Delete via AWS CLI:
aws autoscaling delete-auto-scaling-group --auto-scaling-group-name my-asg
Suppose the group has instances or scaling activities in progress, then we use:
aws autoscaling delete-auto-scaling-group --auto-scaling-group-name my-asg --force-delete
(Optional) Delete the launch configuration
Moving ahead, our Support Techs discusses few options to delete. We can skip them to keep the launch template for future use.
Delete via console:
- First, we open the Amazon EC2 console.
- Then under AUTO SCALING, we select Launch Configurations.
- On that page, we select the launch configuration > Actions > Delete launch configuration.
- For confirmation, we select, Yes, Delete.
Delete via AWS CLI:
aws autoscaling delete-launch-configuration --launch-configuration-name my-launch-config
(Optional) Delete the launch template
It is possible for us to delete the launch template or just one version of the launch template.
Delete via console:
- Initially, we open the Amazon EC2 console.
- Then under INSTANCES, we select Launch Templates.
- We select the launch template and then do one of the following:
- Actions > Delete template > Delete launch template.
- Actions > Delete template version > Select the version > Delete launch template version.
Delete via AWS CLI:
aws ec2 delete-launch-template --launch-template-id lt-068f72b72934aff71
Alternatively, to delete a specific version of a launch template, we run:
aws ec2 delete-launch-template-versions --launch-template-id lt-068f72b72934aff71 --versions 1
(Optional) Delete the load balancer and target groups
Our Support Techs does not recommend this if the Auto Scaling group does not associate with an Elastic Load Balancing load balancer.
Delete load balancer via console:
- Firstly, we open the Amazon EC2 console.
- From under LOAD BALANCING, we select Load Balancers.
- Then we select the load balancer > Actions > Delete.
- Finally, for confirmation, we select Yes, Delete.
Delete target group via console:
- Under LOAD BALANCING, we select Target Groups.
- We select the target group and select Actions > Delete.
- For confirmation, we select Yes.
Delete the load balancer via AWS CLI:
For Application Load Balancers and Network Load Balancers, we use:
aws elbv2 delete-load-balancer --load-balancer-arn my-load-balancer-arn aws elbv2 delete-target-group --target-group-arn my-target-group-arn
For Classic Load Balancers, we use:
aws elb delete-load-balancer --load-balancer-name my-load-balancer
(Optional) Delete CloudWatch alarms
Suppose the Auto Scaling group does not associate with any CloudWatch alarms. Then we skip this section.
Delete via console:
- Initially, we open the CloudWatch console.
- Then we select Alarms on the navigation pane.
- After that, we select the alarms and then Action > Delete.
- For confirmation prompt, we select Delete.
Delete via AWS CLI:
Generally, we can delete one or more alarms at a time.
aws cloudwatch delete-alarms --alarm-name Step-Scaling-AlarmHigh-AddCapacity Step-Scaling-AlarmLow-RemoveCapacity
[Need help with any of the above steps? We are available 24*7]
Conclusion
In short, we saw how our Support Techs delete the auto scaling infrastructure.
0 Comments