"Every new server is set up by hand." That works for one server. It can't work when Auto Scaling launches instances in the middle of the night with nobody watching. For that, the whole setup has to be written down in advance. In EC2, that written-down setup is a launch template.
What a launch template is
A launch template is a saved recipe for launching EC2 instances. It stores the parameters you would otherwise pick by hand in the launch wizard, so every instance comes out the same way, every time.
Typical contents:
- The AMI (machine image): the operating system and software to start from.
- The instance type: the size and family.
- The key pair for SSH access, if you use one.
- The security groups: the firewall rules.
- Storage, an IAM instance profile, tags and network settings.
- User data: a script that runs when the instance first boots, to install or start your application.
All parameters are optional, so a template can be partial. One catch when you use it with Auto Scaling: if the template has no AMI, you can't add the AMI at the group level.
Versions: change safely, roll back quickly
A launch template has versions. You don't edit a version; you create a new one. Version 1 might use last month's image, version 2 the patched one. You choose which version is the default, and an Auto Scaling group can point at a specific version, at the default, or at the latest.
That gives you a simple release process: build a new AMI, create a new template version, roll it out, and if something breaks, point the group back at the previous version. Auto Scaling's instance refresh can replace the running instances gradually when the template changes.
A common mistake is assuming a new version updates servers that are already running. It doesn't. It only affects instances launched afterwards, until you refresh or replace the old ones.
One template, many uses
The same template can launch a single instance, feed an Auto Scaling group, or define a group that mixes several instance types and both On-Demand and Spot capacity. That mix is only possible with launch templates.
Launch configurations: the old way
Before launch templates there were launch configurations. They still exist in older setups, but they are on the way out:
- They can't be modified and have no versions. Any change means creating a new one.
- Since January 1, 2023, new EC2 instance types are no longer supported in them.
- Accounts created on or after October 1, 2024 can't create launch configurations at all.
AWS recommends migrating to launch templates. If you inherit an account that still uses launch configurations, put that migration on the list.
Where AI fits
An inference fleet is the case where "identical every time" matters most. Write one recipe for every inference server:
- a GPU instance type,
- an image with the GPU drivers and frameworks already installed, such as one of the AWS Deep Learning AMIs,
- and a startup script that fetches the model and starts the model server.
Now every server that Auto Scaling adds comes up identical, and a new model release is just a new template version you can roll back. One practical tip: downloading a large model at boot makes scale-out slow, so many teams bake as much as they can into the image and keep the startup script short.
Quick recap
- A launch template is a recipe for launching EC2 instances.
- It has versions: create a new one to change, point back to roll back.
- It works for single instances, Auto Scaling groups and On-Demand plus Spot mixes.
- It replaces launch configurations, which new accounts can no longer create.