
1. Create a Launch Template
A launch template stores the configuration for EC2 instances (AMI, instance type, security groups, user data, and other options). Auto Scaling groups use a launch template to launch consistent instances. Steps:- Click Create launch template.
- Provide a name (for example,
my-template) and an optional description. - Choose an AMI. If your recent AMIs aren’t shown, pick one from Quick Start (Amazon Linux is a common choice).

- Set the instance type to
t3.micro(type “t3” in the dropdown to filter). - Leave Key pair (login) as default if you do not need to SSH into instances immediately.
- Create or select a security group. Example configuration:
Open the Advanced details section and paste your user data script so it runs on instance boot. This example installs Apache (httpd), starts it, and writes a simple index page that displays the instance hostname:
If you use Amazon Linux 2023, the package manager is
dnf instead of yum. Replace yum install -y httpd with dnf install -y httpd and adjust other package-manager commands accordingly.
Hi from <hostname> so you can identify which instance handled a request.
2. Create an Auto Scaling Group
Next, create an Auto Scaling group that uses the launch template to maintain a fleet of identical instances.- Go to Auto Scaling groups in the EC2 console and click Create Auto Scaling group.
- Give the ASG a name (for example,
my-asg) and select the launch template (choose the appropriate version). - Under network settings, select your VPC and choose multiple Availability Zones (e.g.,
2a,2b,2c) for high availability. - Leave the Availability Zone distribution at the default Balanced — best effort.

Attach an Application Load Balancer (ALB)
To distribute incoming HTTP traffic across the ASG instances, attach an ALB during ASG creation:- Choose Attach to a new load balancer.
- Select Application Load Balancer.
- Provide a name (e.g.,
my-elb). - Create a target group (for example,
MyTargetGroup) with protocolHTTPand port80.
- The load balancer security group allows inbound HTTP (port 80).
- The instance security group allows traffic from the load balancer on port 80 (or allow the load balancer’s security group).


Set ASG capacity (Min / Desired / Max)
Choose capacity values to control how many instances the ASG maintains. Example for this demo:
Finish the wizard. The ASG will launch instances based on the launch template and register them with the target group.
Provisioning an ALB can take several minutes (typically 5–10 minutes). Refresh the Load Balancers page until the ALB status becomes active.
3. Verify the setup and access the app
Once the ALB is active:- Open the Load Balancers page.
- Copy the ALB DNS name and open it in your browser:
http://ALB_DNS_NAME/
You should see the index page created by user data, for example:
Hi from ip-172-31-30-195.us-east-2.compute.internal
Refreshing the browser may show different hostnames as the ALB distributes traffic across healthy instances.

4. Cleanup
To avoid ongoing charges, delete resources you no longer need in this order:- Delete the Auto Scaling group: select the ASG → Actions → Delete.
- Delete the Load Balancer: select the load balancer → Actions → Delete.
5. Manually scale an Auto Scaling group
You can manually change the ASG capacity through the console:- Select the ASG → Actions → Edit (or open the Details panel and click Edit).
- Update the
Desired,Min, andMaxcapacity values, then save.

Desired = 3 and Max = 4, then save. Auto Scaling launches another instance and registers it with the target group. Once the instance passes health checks, the ASG will show three healthy instances.

Desired and Min to a lower value (for example, Desired = 2). Auto Scaling will terminate instances until the group reaches the new target capacity—allow a few minutes for instance termination and health-check updates.
That covers the essentials: create a launch template, build an Auto Scaling group, attach an ALB, verify traffic distribution, and manually scale the group.
Links and references
- AWS Launch Templates: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-templates.html
- Amazon EC2 Auto Scaling: https://docs.aws.amazon.com/autoscaling/ec2/userguide/what-is-amazon-ec2-auto-scaling.html
- Application Load Balancer: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html