Introduction To Launch Template

In the previous article Clustering Web Servers Using ELB we saw and have learned AMI, target groups, their different configurations like registering instances in the target group, etc. In this article, we are going to learn and see the concept of Launch Templates and will cover the below topics.
  • Creating Launch Template
  • Launching instance from template
So, let’s get started.
 

Launch Template

 
Launch template, as the name implies, contains all the configurations or settings that are required to launch instances. It simplifies the process of auto-scaling wherein we need a lot of instances to be added automatically in case of specific needs.
 
For this we will need to select the AMI, and we will select the AMI which we created using card-web01 server in the article Clustering Web Servers Using ELB
 
So how we can create launch template?
 
Go to Launch templates under instances -> Create launch template
 
And select the key pair, security group of the card-web01/02.
 
 
 
 
 
 
Here as we can see that we have specified the AMI and given the instance type which is t2.micro in this case and have also selected the same security group that we have created for the web servers card-web01.
 
We have added Tag Name as card-web00 as this is a template. Now just click on Create template button and we can see that our launch template has been successfully created.
 
 
NOTE: Instead of selecting AMI for creating new instance, and then selecting instance type, key pair and security group, we can directly go to launch template and give the no of instances we want to create, as we have saved all the configurations inside the launch template only.
 

Launching Instance from Template

 
By now we have seen how we can create the template, so now it's time to launch some instance(s) using the template. For that, just go to actions and select the option launch Instance from template as shown.
 
 
This will take you to a page where you are required to put additional details like how many instances you want to create using the launch template.
 
We can also add tags for better searching.
 
 
 
Here we can give any number of instances in the number of instances option, that we want to generate.
 
Finally hit Launch instance from template and we can see that our new instance card-web03 has been created successfully.
 
 
Thus, we can see that in just few seconds we can launch the new instances. We can add this newly created instance also in the target group as we registered our other 2 instances i.e. card-web01 and card-web02 respectively.
 
For a launch template, we can create multiple launch template versions and each version of the template can have different parameters to launch the instances.
 
So, if you want to launch a new instance from the launch template then at that time, we can select the launch template version and if we don’t specify any version in particular then the default version is used. Also, we can set any version of the launch template as the default version, but by default the first version of the launch template is considered as the default version of the template.
 
Image source: aws.amazon.com
 
The diagram above shows the different versions of launch template at a given point of time.
  • First version; i.e. version 1, shows the type of instance, AMI Id, subnet and the keypair used to launch an instance.
  • Second version adds security group to the details of the first version.
  • Lastly the third version uses different values for some of the configuration parameters of the launch template. 

Summary

 
In this article, we learned the concept of Launch template and their use case. We also saw practically how we can set up launch template and can create the instances in a matter of a few seconds.
 
I hope you find this article helpful. Stay tuned for more … Cheers!!


Similar Articles