# 4.8-Building the Launch Template

## Manual launch vs. Launch template

In the AWS EC2 (Elastic Cloud Computing), **manually launching** a virtual machine is a **7-steps process**, during which you can or have to choose/specify **many options** :

![The interactive AWS EC2 "Launch Instance" process flow](https://681104499-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhjKavWMofrik61tHfB%2F-Lj5y9ZQxIXbvWaTASyC%2F-Lj5ztyjW7dn-oGGcSPe%2Fimage.png?alt=media\&token=720d0db0-f824-4d4b-a6bf-3b2f2091230d)

{% hint style="success" %}
We'll **facilitate the launch process** here by taking advantage of a relatively recent AWS feature : we'll _record our option choices_ in a "**Launch Template**", that we'll then use **to launch our server in a much quicker way**.
{% endhint %}

### Checking the "free elligible" Instance type in your AWs Region

_Going to the second step above_ : "_**Choose Instance Type**_" (and then pressing **Cancel** to abort the process) _**is a good idea** anyway_, because it will show you **what the "free elligible" Instance type is** for your **current AWS Region** : currently t2.micro or t3.micro.

For example, in Oregon :

![](https://681104499-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhjKavWMofrik61tHfB%2F-Lj7H8IWs43SV0gJlbM7%2F-Lj7aKh3G0Q8j0sv1DiM%2Fimage.png?alt=media\&token=602c0f69-9054-4695-95b5-3515a35fc427)

At step 2 you see that **the "Free tier elligible"&#x20;**_**Instance type**_**&#x20;in Oregon is currently&#x20;**_**t2.micro**_ :

![](https://681104499-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhjKavWMofrik61tHfB%2F-Lj7H8IWs43SV0gJlbM7%2F-Lj7ayhNYky_qflBbVSN%2Fimage.png?alt=media\&token=2f5e8ea8-c554-484c-bf40-a18aa3725227)

You can then click "**Cancel**" to exit the process.

## New _Launch Template_

In the **EC2 console**, let's click "**Launch Templates**" in the menu on the left side, and then "**Create Launch Template**" to get this form :

![Top of the Create Launch Template entry form](https://681104499-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhjKavWMofrik61tHfB%2F-Lj6LpQo_15OffqkkAyj%2F-Lj6xPl76w0hrXrJVqB5%2Fimage.png?alt=media\&token=6b1951ac-297b-4179-8c3a-87a365198659)

For the first part :

* keep "_**What would you like to do ?**_" as "**Create a new template**"
* give a _**Launch template name** like my "my-fg-ovpn-201907" above_
* give a _**Template version description**_ as you whish
* the "_**Source template**_" stays **empty** since this is your first one.

## _**The "Launch template contents" section**_

![Launch template contents](https://681104499-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhjKavWMofrik61tHfB%2F-Lj6LpQo_15OffqkkAyj%2F-Lj7-yEn4uKHb2ns0m2M%2Fimage.png?alt=media\&token=14006c14-bf42-4290-b0dc-3a8a43b20fb4)

### AMI ID

The first choice is about the **AMI** = _**Amazon Machine Image**_. This is like the backup of a pre-built installation, that will be copied over to your own virtual machine to initialize it.

We use the _**Search for AMI**_ link and we'll select one from the "**Quick start**" _**AMI catalog**_ : the "_**Amazon Linux AMI YYYY.MM.v (HVM), SSD Volume Type**_" (YYYY.MM.v = 2018.03.0 as of this writing).

![](https://681104499-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhjKavWMofrik61tHfB%2F-Lj6LpQo_15OffqkkAyj%2F-Lj70Zsfj9ZNQ2VYh-LJ%2Fimage.png?alt=media\&token=87003936-7c1d-48b1-8f3c-862e750e4879)

Your choice will appear as an "**AMI ID**", which is **different for each region** : the same **"**_**Amazon Linux AMI 2018.03.0 (HVM), SSD Volume Type"**_ gives AMI ID = _**ami-8c169ef2**_ in Stockholm while at the same moment it gives _**ami-0bdfa1adc3878cd23**_ in London and _**ami-0f2176987ee50226e**_ in Oregon...

After confirming, the AMI ID is populated in the main form.

### Instance type

The second one is the **Instance type**, defining the size of virtual "core hardware" (CPUs and RAM).  There are [_**many instance types**_](https://aws.amazon.com/ec2/instance-types/), grouped in different families, of _**very different sizes and hourly cost**_ !

{% hint style="info" %}
**We'll use an instance type that is "free elligible" for the AWS region : generally&#x20;**_**t2.micro**_

**(**_**t3.micro**_**&#x20;is "free elligible" ONLY in regions where&#x20;**_**t2.micro**_**&#x20;is not available)**
{% endhint %}

Depending on your region, **one of these 2 types will be available as "free elligible"** :

* either _**t2.micro (generally)**_
* or the recent _**t3.micro in some regions without t2.micro**_

{% hint style="warning" %}
**In AWS regions where BOTH&#x20;**_**t2.micro**_**&#x20;and&#x20;**_**t3.micro**_**&#x20;are available :**

**ONLY&#x20;**_**t2.micro**_**&#x20;is "free elligible"**

**So search for&#x20;**_**t2.micro**_**&#x20;first in the list, and only if not found then choose&#x20;**_**t3.micro**_
{% endhint %}

In **Stockholm as of July 2019**, _t2.micro_ is not available and _t3.micro_ is "free elligible", so **for this demo** **:&#x20;**_**t3.micro**_ it will be and "free elligible" it will remain :

![t3.micro is the "free elligible" instance type in Stockholm (2019/07)](https://681104499-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhjKavWMofrik61tHfB%2F-Lj6LpQo_15OffqkkAyj%2F-Lj7AzB3j1JBcD425kld%2Fimage.png?alt=media\&token=4307fa84-3975-4071-9ab4-80e8f4827620)

### Key pair name

[We only created 1 Key pair](4.5-creating-an-aws-key-pair), so this is an easy choice...

![Select your (only) Key pair name](https://681104499-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhjKavWMofrik61tHfB%2F-Lj6LpQo_15OffqkkAyj%2F-Lj7BkCyHSQWwIoUwG60%2Fimage.png?alt=media\&token=505a231c-a984-4214-93e2-71e80cae0a3e)

### Network type

**VPC !** For a new account, you don't even have access to the legacy "EC2 Classic" _- and you don't even want to know what it was..._

![VPC !](https://681104499-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhjKavWMofrik61tHfB%2F-Lj6LpQo_15OffqkkAyj%2F-Lj7CKZ_WJ8_L3kbN2oN%2Fimage.png?alt=media\&token=b9543967-5a91-4ef2-8725-4f78c35b9a2d)

### Security Groups

[**We created one**](4.6-creating-an-aws-security-group) just for our setup, so **let's select it** !

![](https://681104499-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhjKavWMofrik61tHfB%2F-Lj7H8IWs43SV0gJlbM7%2F-Lj7IjAp66dNIczdcABS%2Fimage.png?alt=media\&token=125de973-c12d-4163-9947-4420cfa1dce0)

_You can see that you can assign multiple security groups, so if you have different security groups for different kinds of network traffic authorization, you can cumulate them._

### Our choices so far, for this demo :

![](https://681104499-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhjKavWMofrik61tHfB%2F-Lj7H8IWs43SV0gJlbM7%2F-Lj7I7Ci6NRlxj--9W_6%2Fimage.png?alt=media\&token=597edeab-0760-4264-a317-0c93e84f4931)

_**As of July 2019, for the "free elligible" instance type, you would have t2.micro instead of t3.micro in most regions other than Stockholm.**_

## _Network Interfaces_, _Storage (Volumes)_ and _Instance tags_

{% hint style="warning" %}
**Step over these three blocks without touching them**
{% endhint %}

We'll use the default network interface and storage options, and we don't need tagging.

## _Advanced details_ : expand !!

![](https://681104499-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhjKavWMofrik61tHfB%2F-Lj7H8IWs43SV0gJlbM7%2F-Lj7L-Ki33k_xKQWaAJN%2Fimage.png?alt=media\&token=d64a7cb7-4101-44be-b4f0-d481ac76ccde)

{% hint style="warning" %}
**We need to specify 2 options in this section :**

* _**IAM instance profile**_
* _**User data**_
{% endhint %}

{% hint style="danger" %}
**Don't touch to the other options !**

_**(unless you're already outside the Free Tier AND you know what you're doing...)**_
{% endhint %}

### IAM instance profile

Here you have to specify the **IAM Role** you [created earlier](4.1-creating-the-iam-role) :

![IAM instance profile : our IAM role created earlier](https://681104499-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhjKavWMofrik61tHfB%2F-Lj7H8IWs43SV0gJlbM7%2F-Lj7M9LJdM91HMe5MG7d%2Fimage.png?alt=media\&token=95fd7eb8-9c48-42dd-9451-77181b88cbdb)

### User data

Here you'll have to **copy/paste the contents of** [**your own "config.name"-userdata.sh**](../4.7-filling-the-bucket#userdata-needs-you)

Here is ours **for this demo** (_with our 2 edited lines highlighted_) :

![Our customized userdata contents](https://681104499-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhjKavWMofrik61tHfB%2F-Lj7H8IWs43SV0gJlbM7%2F-Lj7Onk3bk6eKF1hsuOi%2Fimage.png?alt=media\&token=0a2b19a9-6665-4d36-ad5b-4326bfbd4c1c)

## Now, we can confirm our choices !

By clicking the blue "**Create launch template**" button at the bottom...

![Launch Template successfully created](https://681104499-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhjKavWMofrik61tHfB%2F-Lj7H8IWs43SV0gJlbM7%2F-Lj7QdYNMqRAfd_czz35%2Fimage.png?alt=media\&token=ca7ac723-c93c-43ed-ab7b-251e7661bc4f)

{% hint style="success" %}
**...We now have a&#x20;**_**Launch Template**_**&#x20;ready to use !**
{% endhint %}

