AWS Certified Cloud Practitioner / ELB & ASG - Elastic Load Balancing & Auto Scaling Groups

Auto Scaling Groups (ASG) Hands On

🧹 Clean Start

❌ Terminate old EC2 instances

πŸ‘‰ ASG will create new ones automatically


πŸš€ Create Auto Scaling Group

πŸ“ Navigate

  • EC2 Dashboard β†’ Auto Scaling Groups

  • Click Create Auto Scaling Group

✏️ Name

  • DemoASG


πŸ“¦ Create Launch Template

πŸ’‘ What is this?

πŸ‘‰ Blueprint for EC2 instances

βš™οΈ Configuration

  • Click Create a launch template

  • Name: DemoLaunchTemplate

  • AMI: Amazon Linux 2 🐧

  • Instance Type: t3.micro or t2.micro πŸ’Έ

  • Key Pair: ❌ None

  • Security Group: Existing One (launch-wizard-1)

  • Keep EBS Volumes as default (no change)

  • Advanced details β†’ User Data: βœ… (Hello World script)

#!/bin/bash
# Use this for your user data (script from top to bottom)
# install httpd (Linux 2 version)
yum update -y yum install -y httpd systemctl start httpd systemctl enable httpd
echo "< h1>Hello World from $(hostname -f)</h1>"> /var/www/html/index.html
  • Click Create launch template


πŸ‘‰ Select Launch template

  • Go to Previous Tab (Create Auto Scaling group page)

  • Select Launch Instance (Refresh few times to reflect)

  • Then Click Next


🌍 Network & Availability Zones

  • In Choose instance launch options

  • Select multiple AZs 🌍

  • Enables High Availability

  • Click Next


βš–οΈ Attach to Load Balancer

  • Select: Attach to existing load balancer

  • Choose: demo-tg-alb

  • βœ… EC2 Health Check

  • βœ… ELB Health Check

πŸ‘‰ Ensures only healthy instances receive traffic

  • Click Next


πŸ“Š Configure Group Size

Min = 1
Desired = 2
Max = 4
  • Keep Automatic Scaling - Optional as Default

  • Instance maintenance policy - No policy

  • And rest other as default values

  • More on these later

  • Click Next


Skip Add Notifications and Add Tags sections

🧐 Review and Create ASG

  • Review the details

  • Click Create auto scaling group


🧠 Checking our Auto Scaling Group

Navigate to:

Auto Scaling Group β†’ Activity

Shows all scaling events such as:

  • Launching EC2 instances

  • Terminating EC2 instances

  • Replacing unhealthy instances

Example:

  • Desired capacity changed from 0 β†’ 2

  • ASG launches 2 EC2 instances

  • Maybe other things also

Navigate to:

Auto Scaling Group β†’ Instance Management

You can see instance states:

  • Pending

  • In Service

  • Terminating

Health :

  • Healthy

  • Unhealthy


πŸ§ͺ Verify Setup

βœ… Check EC2

You’ll see new instances created by ASG

βœ… Check Target Group

Check instances healthy now its Unhealthy 😒 but give it some time it will be healthy ❀️

You can also change Health Check settings to change Health Status requirements

  • Go to Health Checks and Click Edit

  • Click Advanced health check settings

  • Change Healthy threshold to 2

  • Change Timeout to 2 seconds

  • Change Interval to 5 seconds

  • Click Save Change

  • Now go back to Targets and Refresh after some time you should see your Instances Healthy

If the instance still isn't healthy 🚨, there's likely something wrong on the instance itself β€” worth digging in and troubleshooting from your end πŸ”§

πŸ’‘ Tip: Amazon Q (the AWS chatbot) πŸ€– is a great resource for working through issues like this.