Creating an EC2 Instance: Launch Templates
Learn how to use launch templates to simplify the deployment of EC2 instances.
We'll cover the following
There is one last feature of EC2 that we should take a look at, and it unifies all the lessons we have done so far. This is EC2 launch templates.
EC2 launch templates allow us to preconfigure most of the settings of an EC2 instance and store them in a launch template that we can reuse to create EC2 instances. By using launch templates, we don’t need to specify all options again each time, but we can refer to the launch template instead.
Launch templates support versioning as well, so we can gradually build our application (and roll back to older versions if needed). By the way, this is exactly what we will be doing in this course.
Let’s take a look at the launch template from within the EC2 Console.
EC2 console: Launch templates
-
Open the EC2 Console, and go to “Launch Templates” on the left-hand sidebar (see slide 1). Click on “Create Launch Template” to see all the options. We will create a launch template through the AWS Console and later review it via the CLI. For this launch template, we will recreate the web server from the last lesson.
-
Let’s start to fill out the parameters of the launch template. First, we need to give it a name, so let’s call it
WebServer
. This is a required field for each launch template. The version description is optional but useful nonetheless. Please put inSimple WebServer
(see slide 2). We can ignore “Auto Scaling guidance” for now, and we don’t need to set any “Template tags” either, so let’s scroll down further and select an AMI (see slide 3). We can use the first one in the list, the most recent Amazon Linux. -
Next, we should select the instance type. As usual, we can pick
t2.micro
here. By the way, did you notice the option “Don’t include in launch template”? This is a very cool feature of launch templates. We don’t need to specify all parameters, only the ones we want to stay fixed. For example, if we create an instance from a launch template and don’t specify the instance type, we can set it during the creation. This allows us to use launch templates flexibly for multiple variants (see slide 4). -
Just to recap, this is what the screen should look like now—both the Amazon Linux AMI and the instance type
t2.micro
are selected (slide 5).
Get hands-on with 1400+ tech skills courses.