01 Run describe-auto-scaling-groups command (OSX/Linux/UNIX) to list the names of the Auto Scaling Groups available within the selected AWS region:
aws autoscaling describe-auto-scaling-groups
--region us-east-1
--output table
--query 'AutoScalingGroups[*].AutoScalingGroupName'
02 The command output should return a table with the requested ASG names:
---------------------------
|DescribeAutoScalingGroups|
+-------------------------+
| MyWebAppASG |
| MyBackendASG |
| ProdCacheASG |
+-------------------------+
03 Run describe-load-balancers command (OSX/Linux/UNIX) using the name of the ASG that you want to examine as identifier to expose the load balancers associated with it:
aws autoscaling describe-load-balancers
--region us-east-1
--auto-scaling-group-name MyWebAppASG
04 The command output should return the metadata of each load balancer added to the ASG:
If the LoadBalancers property returns an empty array as its value ( i.e. [ ] ), the selected ASG is not currently associated with an Elastic Load Balancer.
05 Run describe-auto-scaling-groups command (OSX/Linux/UNIX) to describe the selected AWS Auto Scaling Group configuration. The following command example provides information about an ASG named MyWebAppASG available in the US-East-1 region:
aws autoscaling describe-auto-scaling-groups
--region us-east-1
--auto-scaling-group-names MyWebAppASG
06 The command output should return the selected Auto Scaling Group configuration metadata:
{
"AutoScalingGroups": [
{
...
"AutoScalingGroupName": "MyWebAppASG",
"DefaultCooldown": 300,
"MinSize": 1,
"Instances": [],
"MaxSize": 2,
"VPCZoneIdentifier": "subnet-19e7cc6f,subnet-4c377014",
...
}
]
}
If the Instances property returns an empty array as its value (as shown in the output example above), the selected ASG does not have any EC2 instances attached.
Based on the information returned at step no. 4 and 6, if the selected Auto Scaling Group is not associated with a load balancer and it doesn't have any instances assigned, it should be marked as empty then safely removed from your AWS account.
07 Repeat steps no. 3 – 6 to identify other empty ASGs available in the current region.
08 Repeat steps no. 1 – 7 to repeat the entire audit process for other AWS regions.