Launch Templates is a new capability from AWS that allows one to launch servers for an Auto Scale group, Spot Fleet and the regular On-demand model using a template. The template contains all the parameters within its configuration that are needed to launch EC2 instances. Though it is possible to leave some things out like the Instance type, which could be selected if trying to launch using Spot Fleet service.
At first I was not sure how launch templates were going to be helpful, however, it did not take long for me to figure out how useful they are. Let me go over some of the reasons why I love this new capability.
- The template can be fully populated with all the required information you need to launch an instance or you could leave few of the things out, like instance type or Availability Zone in the case of launching Spot Instances.
- You can create launch template versions and each version can have a different configuration parameter. You could have a different security group or AMI or key pair or instance type in versions.
- A single template could be used for creating instances with varying parameters for production, dev and test environment.
- Very easy to launch a spot fleet using launch templates.
- AWS has made it very easy to create launch templates. It can be done from cli, console and you can even create one form a running instance or from an existing launch configuration used in your Auto Scale group.
I have gone ahead and converted all of my launch configurations into launch templates using the console.
Let us go over the process of creating a launch template from a running server using the console.
Select an instance in your account and click on Action. You will see the option to ‘Create Template From Instance’
After you select this a new screen shows up which has some details filled in.
Provide a name for the launch template, verify if the AMI pre-filled is the correct one and exists. If you have deleted the AMI after launching the server for any reason then use the correct ami-id.
In this section, you could add another interface or a disk if needed.
Verify your Tags that will be used for the instance.
Click on the button at the bottom ‘Create Template From Instance’ and your template will be created if no errors are detected.
This is the easiest way to create a launch template. The steps shown above were just a guide. You may want to explore other configuration details in the Advanced detail section which allow you to specify many other options or change runtime behavior like EBS-optimized, T2/T2 Unlimited, Monitoring option.