Bootstrap FreeKB - Amazon Web Services (AWS) - List Auto Scaling Group using the AWS CLI
Amazon Web Services (AWS) - List Auto Scaling Group using the AWS CLI


This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.

An Auto Scaling Group let's you automatically start and stop EC2 instances based on some condition, such as creating and starting up EC2 instances when requests load is high or stopping and terminating EC2 instances when requests load is low. This is often used in conjunction with CloudWatch Alarms, where the Alarm checks some condition such as requests load or CPU Utilization and then invokes the Auto Scaling Group to create/startup EC2 instances or to stop/terminate EC2 instances. For example, you may have an Auto Scaling Group that has minimum 1 and maximum 3, meaning that the Auto Scaling Group will have 1 EC2 instance when load is low and scale up to 3 EC2 instances when load is high.

An Auto Scaling Group often uses an EC2 Launch Template. An EC2 Launch Template is a way to set certain defaults for launching a new EC2 instance, such as the SSH Key Pairs, Network Subnets, Security Groups, Amazon Machine Image, et cetera that the EC2 Instance will have.

The aws autoscaling describe-auto-scaling-groups command can be used to list the Auto Scaling Groups you have created.

~]$ aws autoscaling describe-auto-scaling-groups
{
    "AutoScalingGroups": [
        {
            "AutoScalingGroupARN": "arn:aws:autoscaling:us-east-1:123456789012:autoScalingGroup:c21a1c8a-3c0a-4410-89e2-015100f3707f:autoScalingGroupName/my-auto-scaling-group",
            "ServiceLinkedRoleARN": "arn:aws:iam::123456789012:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling",
            "TargetGroupARNs": [],
            "SuspendedProcesses": [],
            "LaunchTemplate": {
                "LaunchTemplateName": "my-launch-template",
                "Version": "$Default",
                "LaunchTemplateId": "lt-05e7ea42c9f2776b7"
            },
            "Tags": [],
            "EnabledMetrics": [],
            "TerminationPolicies": [
                "Default"
            ],
            "AutoScalingGroupName": "my-auto-scaling-group",
            "DefaultCooldown": 300,
            "MinSize": 1,
            "Instances": [
                {
                    "ProtectedFromScaleIn": false,
                    "AvailabilityZone": "us-east-1a",
                    "LaunchTemplate": {
                        "LaunchTemplateName": "my-launch-template",
                        "Version": "1",
                        "LaunchTemplateId": "lt-05e7ea42c9f2776b7"
                    },
                    "InstanceId": "i-087adffe5761b1ce3",
                    "HealthStatus": "Healthy",
                    "LifecycleState": "Pending",
                    "InstanceType": "t2.small"
                }
            ],
            "MaxSize": 2,
            "VPCZoneIdentifier": "subnet-0f35c3586e5090314",
            "HealthCheckGracePeriod": 300,
            "LoadBalancerNames": [],
            "CreatedTime": "2024-02-07T02:50:08.756Z",
            "AvailabilityZones": [
                "us-east-1a"
            ],
            "HealthCheckType": "EC2",
            "NewInstancesProtectedFromScaleIn": false,
            "DesiredCapacity": 1
        }
    ]
}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 30bb32 in the box below so that we can be sure you are a human.