Configuring Launch Templates and Auto Scaling Groups
This lesson explains how Amazon EC2 Auto Scaling keeps the right number of healthy instances running, central to Domain 2 and to questions about scaling, availability, deployment and troubleshooting.
Learning outcomes
After completing this lesson, you will be able to:
- Configure launch templates.
- Configure group capacity, subnets and load balancer integration.
- Mix Spot and On-Demand capacity.
Launch templates
A launch template specifies how instances are launched: AMI, instance type (or a set of types), key pair, security groups, IAM instance profile, user data, EBS volumes, metadata options (require IMDSv2), tags and network settings. Templates are versioned; an Auto Scaling group references a specific version, $Latest or $Default. Launch configurations are the legacy equivalent: they cannot be modified, do not support newer features and can no longer be created for new instance types, so AWS recommends migrating to launch templates. The AMI ID can be a Systems Manager parameter reference so that the newest image is always used.
Launch templates
Group configuration
An Auto Scaling group has a minimum, maximum and desired capacity, a list of subnets in several AZs, and optionally target groups or a Classic Load Balancer to register instances with. Auto Scaling balances instances evenly across AZs and rebalances after an AZ recovers. A mixed instances policy combines several instance types and purchase options, for example a base of On-Demand instances plus Spot instances spread across six types with the price-capacity-optimized allocation strategy; attribute-based instance type selection lets you specify vCPU and memory ranges instead of types. Capacity Rebalancing launches a replacement when a Spot instance receives a rebalance recommendation.
aws autoscaling create-auto-scaling-group --auto-scaling-group-name web-asg \
--launch-template LaunchTemplateName=web-lt,Version='$Latest' \
--min-size 2 --max-size 12 --desired-capacity 4 \
--vpc-zone-identifier "subnet-0a,subnet-0b,subnet-0c" \
--target-group-arns arn:aws:elasticloadbalancing:eu-west-1:111122223333:targetgroup/web/abc123 \
--health-check-type ELB --health-check-grace-period 120 --default-instance-warmup 180The following diagram shows a group combining an On-Demand base with diversified Spot capacity.

Group settings
Spreading a group across Spot and On-Demand
A stateless batch-processing tier must run at least four instances reliably but can use cheaper capacity beyond that. The group's mixed instances policy sets an On-Demand base capacity of 4 and 0% On-Demand above base, with Spot instances from c7g.xlarge, c6g.xlarge, m7g.xlarge and m6g.xlarge using the price-capacity-optimised strategy, across three AZs. Capacity Rebalancing is enabled. When Spot capacity of one type is reclaimed, the group replaces it with another type, and the four On-Demand instances keep the minimum service level.
Should new groups use launch configurations?
Show answer
No. They are legacy; use versioned launch templates.
Exam Tips
Remember for the exam
- Use versioned launch templates; launch configurations are legacy.
- Groups balance instances across AZs in their subnets.
- Mixed instances policies combine On-Demand base capacity with diversified Spot.
- Reference an SSM parameter for the AMI to pick up new images automatically.