Launch Templates
Part of the AWS Roadmap
In short
When traffic spikes at midnight, Auto Scaling has to build new servers without asking you anything. A launch template is the exact recipe it follows.
A launch template stores instance settings such as AMI, instance type, key pair, security groups and user data, with versioning. Auto Scaling groups use launch templates to know how to create new instances.

Think of it like this
The franchise recipe card
Every outlet of a dosa chain from Bengaluru to Delhi uses the same printed recipe card: batter ratio, pan temperature, which chutneys go on the plate. A new outlet opens and its dosas taste the same on day one. When the recipe changes, head office prints version 2. A launch template is that card for EC2: AMI, instance type, security groups and startup script, with versions.
Watch it happen
Template versions
Top of the stack is coloured
1/4The first version. The ASG is set to use $Default, which is v1.
The big ideas
What you need to know
What it stores
AMI, instance type, key pair, security groups, IAM instance profile, EBS volumes, metadata options and user data.
Versions
Each change creates a new numbered version. ASGs can follow $Default, $Latest or a fixed number.
Require IMDSv2
Set HttpTokens to required so the instance metadata service needs a session token, which blocks a common credential-theft trick.
Launch configurations are legacy
The older launch configurations are being phased out and miss newer features. Use launch templates for everything new.
See it in code
Walk through the code
1cat > lt-data.json <<'EOF'2{3 "ImageId": "ami-0abcdef1234567890",4 "InstanceType": "t3.small",5 "IamInstanceProfile": { "Name": "shop-web-profile" },6 "SecurityGroupIds": ["sg-0app1234567890abc"],7 "MetadataOptions": { "HttpTokens": "required" },8 "TagSpecifications": [{9 "ResourceType": "instance",10 "Tags": [{ "Key": "Project", "Value": "shop" }]11 }],12 "UserData": "IyEvYmluL2Jhc2gKc3lzdGVtY3RsIHN0YXJ0IHNob3AtYXBwCg=="13}14EOF15 16aws ec2 create-launch-template \17 --launch-template-name shop-web \18 --version-description "v1 t3.small" \19 --launch-template-data file://lt-data.json1/6Which AMI to boot and what size of instance.
AWS CLI v2. UserData must be base64 encoded. Here it decodes to a two-line bash script that starts the app service.
Save yourself the pain
Common mistakes
Oops
Updating the template and expecting running instances to change.
Do this instead
Templates only affect new launches. Start an instance refresh on the ASG to roll existing instances onto the new version.
Oops
Putting secrets in user data.
Do this instead
User data is readable by anyone who can describe the instance. Fetch secrets at boot from Secrets Manager using the instance role.
Your mission
Template, version, refresh
Quick check
You changed the AMI in a new template version and set it as default. What happens to running instances?
Go deeper
- 1Create a launch template with your Nginx user data script.
- 2Make a new version with a different instance type and set it as default.
- 3Use an instance refresh on the Auto Scaling group to roll out the new version.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.