> ## Documentation Index
> Fetch the complete documentation index at: https://cloud-architect.ipoint-labs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create and Configure Amazon EC2 Auto Scaling with Launch Templates

> Hands-on lab · 55m

Launch this lab in the IP Lab Portal, then follow the steps below in the AWS console.

<a className="ip-lab-portal-btn" href="https://labs.intellectualpoint.com/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates" target="_blank" rel="noreferrer">
  Open IP Lab Portal
</a>

## Overview

### Lab Details

1. This lab walks you through the steps to create and configure an Amazon EC2 Auto Scaling with Launch templates using the AWS Management Console.
2. You will practice using Amazon Machine Image (AMI) to launch Amazon EC2 Instances using Launch templates and will use key pairs for SSH authentication to log into your instance.
3. You will create a web page and publish it.
4. Duration: **55 minutes**
5. **AWS Region: US East (N. Virginia) us-east-1**

### Architecture Diagram

<img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/001.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=11b72ebf2760ea2cfec06c356bc409d1" alt="" width="1112" height="664" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/001.png" />

### Task Details

1. Sign into AWS Management Console.
2. Create a security group for Launch template
3. Create a key pair for the Launch template.
4. Create a launch template
5. Create an EC2 Auto Scaling group
6. Test Auto scaling group

### Launching Lab Environment

1. To launch the lab environment, Click on the **Start Lab** button.

2. Please wait until the cloud environment is provisioned. It will take less than a minute to provision.

3. Once the Lab is started, you will be provided with **IAM user name**, **Password**, **Access** **Key**, and **Secret** **Access** **Key**.

> **Note** : You can only start one lab at any given time

## Lab guide

### Lab Steps

#### Task 1: Sign in to AWS Management Console

1. Click on the **Open Console** button, and you will get redirected to AWS Console in a new browser tab.
2. On the AWS sign-in page,

* Leave the Account ID as default. Never edit/remove the 12 digit Account ID present in the AWS Console. otherwise, you cannot proceed with the lab.
* Now copy your **User Name** and **Password** in the Lab Console to the **IAM Username and Password** in AWS Console and click on the **Sign in** button

3. Once Signed In to the AWS Management Console, Make the default AWS Region as **US East (N. Virginia) us-east-1.**

#### Task 2: Create a Security Group for Launch template

1. Make sure you are in the **N.Virginia** Region.
2. Navigate to **EC2** by clicking on the **Services** menu available under the **Compute** section.
3. On the left panel menu, select the security group under the Network **& Security** section.
4. Click on the **Create Security Group**.
5. We are going to create a Security group for the Launch template with port 80 number enabled.

   * Security group name: Enter ***Launch-template-SG***
   * Description: Enter ***Security group for Launch template***
   * VPC: Select **Default VPC**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/002.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=08936ca925ed8861629cef22c2bf7a4d" alt="" width="2054" height="824" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/002.png" />

* Click on the **Add rule**  under **Inbound rules.**

  * Type : Select **HTTP**
  * Source : Select **Anywhere-IPv4**
  * In the textbox add **0.0.0.0/0**

    <img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/003.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=ea8b0e628fef33492417279e45a886a5" alt="" width="1210" height="254" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/003.png" />

6. Leave everything as default and click on the **Create Security Group**.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/004.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=2b46acefc8cb400705d84906b82b3bcb" alt="" width="1234" height="140" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/004.png" />

#### Task 3: Create a Key pair for the Launch template

1. In the left navigation pane (scroll down) within **Network & Security**, click on the **Key Pairs**.
2. To create a new key pair, click on the **Create Key Pair**.
3. Fill in the details below:

   * Name: Enter ***WhizKeyPair***
   * File format: **pem (Linux & Mac Users)** or **ppk (Windows users)**
   * Leave other options as default.
   * Click on the  **Create Key Pair**.

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/005.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=e4400b9575848fd1085b26d06774f3b9" alt="" width="1443" height="631" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/005.png" />
4. Key pair will be created.

#### Task 4: Creating a Launch template

1. In the left navigation pane (scroll down) within **Instances**, click on the **Launch Templates**
2. Click on the **Create Launch Template**
3. Under **Launch template name and description** section:

   * Launch template name: Enter **whizlabsLC**
   * Template version description: Type **Launch template for whizdemo**
   * **Leave other options as default.**

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/006.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=1f5e910225753f5fb6a24fc74546e9ff" alt="" width="685" height="426" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/006.png" />
4. Under Launch template contents:

   * Amazon machine image (AMI): Select **Amazon Linux 2023 kernel-6.1 AMI.**

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/007.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=3c0db53edeafcdcd77bde403c9b66e4c" alt="" width="1192" height="637" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/007.png" />
   * Under Instance type:

     * Select **t2.micro** from the below list.

       <img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/008.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=d9268e14cd07c6c4d053a488a748b5b6" alt="" width="1184" height="267" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/008.png" />

* Key pair (Login): Select **WhizKeyPair**

  <img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/009.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=f90b2411e8a2619625e9fa61b28c52df" alt="" width="1154" height="207" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/009.png" />
* Networking settings:

  * Firewall(security groups): Select **Select existing security group**
  * Security groups: Select **Launch-template-SG** from the drop-down

<img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/010.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=e5afe28ed4235ff7422593ee7da8d10e" alt="" width="878" height="457" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/010.png" />

* Leave all other options as **default**.
* Expand the option of **Advance details**, Go to the **User data** at the bottom of the page and paste the below script.

\#!/bin/bash

```python theme={null}
dnf update -y
dnf install -y httpd
systemctl start httpd
systemctl enable httpd
echo "<html><h1>Response coming from Amazon Linux 2023 Server</h1></html>" > /var/www/html/index.html 
```

9. To create, click on the **Create launch template**. Upon successful creation, it will create a Launch template. Click on **View launch templates** button.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/011.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=a5eac143634476a053238a4102a410b8" alt="" width="1210" height="154" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/011.png" />

#### Task 5: Create an Auto Scaling Group

1. An Auto Scaling group is a scalable collection of EC2 instances. When you create an Auto Scaling group, you include information such as the subnets for the instances and the number of instances the group must maintain at all times.
2. Go to the left menu under EC2 and choose **Auto Scaling Groups** under **Auto Scaling.**
3. Click on the **Create Auto Scaling Group**.
4. **Step 1 : Choose launch template**

   * Auto Scaling group name : Enter **Whiz-ASG**
   * Select the Launch template **whizlabsLC** from the list. Leave everything as default and click on the **Next**

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/012.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=2166679a97765f5d188fd58723229e40" alt="" width="1123" height="496" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/012.png" />
5. **Step 2: Choose instance launch options**

* VPC: Select the **Default VPC** from the list.
* Subnet: Select any **two subnets** for your Auto Scaling instances.
* Click on the **Next**

  <img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/013.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=4d2519db2af969b5d27a048730e07281" alt="" width="1396" height="711" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/013.png" />

6. **Step 3: Integrate with other services**

* No changes needed in this page, click on the **Next**

7. **Step 4: Configure group size and scaling**

* Under Group size - optional
* Desired capacity : Enter **2**
* **Under Scaling:**
* Minimum capacity : Enter **2**
* Maximum capacity : Enter **2**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/014.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=3867572ec0554509780f6bae4431ab94" alt="" width="1296" height="707" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/014.png" />

* Under Automatic Scaling - optional

  * Select **No scaling policies**

    <img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/015.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=2da8c23c3588a81bbab8241c813bf969" alt="" width="1416" height="624" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/015.png" />
* Under Instance scale-in protection

  * No changes are needed, click on the **Next**

8. **Step 5: Add notifications**

   * No changes are needed in this page, click on the **Next**
9. **Step 6: Add tags**

   * Enter tags in key-value pairs to identify your auto scaling group **instances**.

     * Key : Enter **Name**
     * Value : Enter **Whiz**

       <img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/016.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=1a8a0550439fe286f5ecb287e1a93a19" alt="" width="1510" height="468" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/016.png" />
   * Click on the **Next**
10. Now Review, scrolldown and click on the **Create Auto Scaling Group**.
11. You will be redirected to the autoscaling group page, you will be able to see that two instances are launched by the autoscaling groups

    <img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/017.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=3d072740200dad077c90c12d119e6225" alt="" width="1406" height="211" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/017.png" />
12. Now go to the EC2 instances list. You will see that there are **two new running instances** (which were created by your autoscaling group) You can confirm this from their tag name, which you gave at the time of creating the autoscaling group.
13. You have successfully created an autoscaling group with a policy to a minimum of **2** and a maximum of **2** instances.

#### Task 6: Test Auto Scaling Group

1. For testing the auto-scaling policy, go to the EC2 instance list and select one of your instances.
2. To terminate the EC2 instances manually:

   * Select one of the instances randomly
   * Click on the **Instance state**
   * Choose to terminate the instance by clicking on **Terminate instance.**

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/018.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=3237dbf2e6cc9e4cb0daa23a0f178614" alt="" width="1217" height="202" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/018.png" />
3. Confirm the termination by clicking on the Terminate button.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/019.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=84375f8cb80269ced81ef69784c58ec8" alt="" width="844" height="413" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/019.png" />
4. This will terminate your instance.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/020.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=184614af87d4e7167ca052f384a76053" alt="" width="2242" height="622" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/020.png" />
5. Once your instance is terminated. You can go to the **Auto scaling groups** page and see the **Instances is 1** and the **Status** is **Updating capacity**

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/021.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=f9a37924a1b2f37c90b4ba9b60eef6f4" alt="" width="1203" height="205" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/021.png" />
6. Alternatively, you can look for the **Activity history** under **Activity** of your Auto scaling group to see what happened.
7. Meanwhile, A new instance will be launched to fulfill the policy condition.
   A sample screenshot is provided below:

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/022.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=81aee5c55f8bbed96b84da1d19f42940" alt="" width="1215" height="222" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/022.png" />

> **Note:** Launching a new instance may take up to 5 minutes, you can refresh the page to view the new instance.

> **Do you Know ?**
> Launch templates support versioning, allowing you to create and manage multiple versions of a template. This enables you to easily roll back to previous configurations or test new settings without impacting existing Auto Scaling groups.

1. Once the lab steps are completed, please click on the **Validation** button on the left side panel.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/yBF63qR2wAtC6-S5/images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/023.png?fit=max&auto=format&n=yBF63qR2wAtC6-S5&q=85&s=7cb5b737fbd90d277acc8a2aa3a66692" alt="" width="936" height="507" data-path="images/labs/create-and-configure-amazon-ec2-auto-scaling-with-launch-templates/023.png" />

### Completion and Conclusion

1. You have created a security group and key pair for the Launch template.
2. You created a **Launch template** and **Auto Scaling**.
3. You have launched two EC2 instances through Auto scaling.
4. You have tested the Auto scaling by terminating one of the instances manually.

### End Lab

1. Sign out of the AWS Account
2. You have successfully completed the lab.
3. Once you have completed the steps, click on **End Lab** from the IP Lab Portal dashboard.

## What gets checked

When you press **Check my work**, the platform verifies each of these:

* **Launch an EC2 Instance** — Check whether an EC2 Instance is launched or not.
* **Create Amazon EC2 Auto Scaling Group** — Check whether an Auto Scaling Group is created or not.
* **Create Amazon EC2 Launch Template** — Check whether an EC2 Launch Template is created or not.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.