> ## 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.

# Introduction to Amazon Auto Scaling

> 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/introduction-to-amazon-auto-scaling" target="_blank" rel="noreferrer">
  Open IP Lab Portal
</a>

## Overview

### Lab details

1. AWS Auto Scaling is a service that automatically adjusts the number of Amazon EC2 instances in a group based on specified conditions and policies. The lab aims to guide users through the process of creating a Launch Template, setting up an Auto Scaling group, and testing the scaling behavior.
2. Duration: **55 minutes**
3. AWS Region: **US East (N. Virginia) us-east-1.**

### Introduction

#### What is Amazon EC2 Auto Scaling

* Amazon EC2 autoscaling is designed as a fully managed service that controls the number of running instances, in case your workload is higher, it will match by launching more instances instantaneously.
* Unlike load balancer, you don’t provision EC2 Instances in advance and register as a target but you define the whole configuration in the Launch template which will scale out or scale in based on the traffic.
* In auto-scaling, you also define what will be minimum capacity, desired capacity, and maximum capacity. Autoscaling makes sure that the number of instances specified in desired capacity is always running when traffic is normal, it will scale in when traffic is lowest and scale-out when running there is a spike.
* While creating auto-scaling, it requires a Launch template where you specify which AMI to choose, what will be instance type, security group associated, and all other options required to launch an EC2 Instance including key pair.

#### #### What is the difference between Launch Templates (LTs) and Launch Configuration (LCs)

* AWS Recommends using Launch Templates (LTs) over Launch Configurations (LCs) because LTs provide the latest features.
* Launch configurations are immutable in nature, once you create, you can't edit them, so replacement is the only option. Where Launch template provides versioning, at a time you can create multiple versions and make one of them as default for use.
* Using Launch templates, you can use the T2 Unlimited burst feature.
* Launch templates allow provisioning both On-demand and Spot Instances.
* Launch templates are compatible to use with AWS Management Console, AWS SDK, and AWS CLI.

### Architecture diagram

<img src="https://mintcdn.com/ip-cloud-architect-pathway/S7TRbFaK099mvCQ6/images/labs/introduction-to-amazon-auto-scaling/001.png?fit=max&auto=format&n=S7TRbFaK099mvCQ6&q=85&s=e96e2c3865296db72f981d8277b6bdd3" alt="" width="1020" height="620" data-path="images/labs/introduction-to-amazon-auto-scaling/001.png" />

<img src="https://mintcdn.com/ip-cloud-architect-pathway/S7TRbFaK099mvCQ6/images/labs/introduction-to-amazon-auto-scaling/002.png?fit=max&auto=format&n=S7TRbFaK099mvCQ6&q=85&s=c440abf34e9ed4e8132e5c2487a20aa7" alt="" width="1060" height="860" data-path="images/labs/introduction-to-amazon-auto-scaling/002.png" />

### Task details

1. Sign in to AWS Management Console.
2. Creating Launch Template
3. Create an Auto Scaling group
4. Test the Auto Scaling Group.
5. Validation of the lab

### Launching the lab environment

1. To launch the lab environment, click on the **Launch 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 username**, **Password**, **Access** **Key**, and **Secret** **Access** **Key**.

<Note>
  You can only start one lab at any given time
</Note>

## 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 **Username** 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.**

<Note>
  If you face any issues, please go through [**FAQs and Troubleshooting**](/aws-cp/support/faqs-and-troubleshooting).
</Note>

#### Task 2: Provision Default VPC

1. Navigate to **VPC** by clicking on the **Services** menu in the top, then click on **VPC** or Open the Amazon VPC console via [https://console.aws.amazon.com/vpc/.](https://console.aws.amazon.com/vpc/)
2. Delete the **default VPC** by following the **below steps:**

   * In the navigation pane, choose **Your VPCs.**
   * Select the **VPC** with value as **yes** in **default VPC column.**

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/XSV9k1lByEDPG3uu/images/labs/allocating-elastic-ip-and-associating-it-to-ec2-instance/002.png?fit=max&auto=format&n=XSV9k1lByEDPG3uu&q=85&s=260654227dccbb825fd9902fad70aef1" alt="" width="1644" height="174" data-path="images/labs/allocating-elastic-ip-and-associating-it-to-ec2-instance/002.png" />
   * Go to **Actions button** and click on **delete VPC button**

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/XSV9k1lByEDPG3uu/images/labs/allocating-elastic-ip-and-associating-it-to-ec2-instance/003.png?fit=max&auto=format&n=XSV9k1lByEDPG3uu&q=85&s=4cac489eac16bfa146cd8557d9967b9c" alt="" width="1648" height="295" data-path="images/labs/allocating-elastic-ip-and-associating-it-to-ec2-instance/003.png" />
   * Check **I acknowledge that I want to delete my default VPC** option.
   * Type **delete default VPC** and click on **Delete button**

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/XSV9k1lByEDPG3uu/images/labs/allocating-elastic-ip-and-associating-it-to-ec2-instance/004.png?fit=max&auto=format&n=XSV9k1lByEDPG3uu&q=85&s=ba53e0d6505a53b827c43d121884927a" alt="" width="832" height="806" data-path="images/labs/allocating-elastic-ip-and-associating-it-to-ec2-instance/004.png" />
3. Now to provision **Default VPC** again

   * Refresh your console go to **Actions** and click **Create default VPC**

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/XSV9k1lByEDPG3uu/images/labs/allocating-elastic-ip-and-associating-it-to-ec2-instance/005.png?fit=max&auto=format&n=XSV9k1lByEDPG3uu&q=85&s=9b61a3ced1c5e03afb2c27564fde0298" alt="" width="1650" height="266" data-path="images/labs/allocating-elastic-ip-and-associating-it-to-ec2-instance/005.png" />
   * Click **Create default VPC button** and your default VPC will be created

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/XSV9k1lByEDPG3uu/images/labs/allocating-elastic-ip-and-associating-it-to-ec2-instance/006.png?fit=max&auto=format&n=XSV9k1lByEDPG3uu&q=85&s=87ae7a34b9236b3fd5e03a24f7856576" alt="" width="842" height="312" data-path="images/labs/allocating-elastic-ip-and-associating-it-to-ec2-instance/006.png" />

<Note>
  If you are unable to delete the default VPC, please visit our [FAQs and Troubleshooting](/aws-cp/support/faqs-and-troubleshooting) for step-by-step instructions.
</Note>

<img src="https://mintcdn.com/ip-cloud-architect-pathway/XSV9k1lByEDPG3uu/images/labs/allocating-elastic-ip-and-associating-it-to-ec2-instance/008.png?fit=max&auto=format&n=XSV9k1lByEDPG3uu&q=85&s=e87a41c2a40f2bbeb3d6b2e665e5d72e" alt="" width="1387" height="751" data-path="images/labs/allocating-elastic-ip-and-associating-it-to-ec2-instance/008.png" />

#### Task 3: Creating Launch Template

In this task, we are going  to create Launch Templates, which are a recommended approach for creating instances in Auto Scaling groups. By creating a Launch Template, we define the configuration settings for their EC2 instances, including the Amazon Machine Image (AMI), instance type, network settings, and security groups.

1. Make sure you are in the **US East (N. Virginia) us-east-1** Region before proceeding with the Lab.
2. Navigate to **EC2** by clicking on the **Services** menu in the top, then click on **EC2** in the **Compute** section.
3. In the left navigation menu, scroll down to **Launch Templates** and click on **Create launch template** button.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/S7TRbFaK099mvCQ6/images/labs/introduction-to-amazon-auto-scaling/003.png?fit=max&auto=format&n=S7TRbFaK099mvCQ6&q=85&s=f22ac72cbd5ebfc8993cdfd82983ddcb" alt="" width="516" height="149" data-path="images/labs/introduction-to-amazon-auto-scaling/003.png" />

4. Launch template name: Enter **whizlabsLT**
5. Template version description: Enter **Launch template version 1**
6. Launch template contents:

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

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/S7TRbFaK099mvCQ6/images/labs/introduction-to-amazon-auto-scaling/004.png?fit=max&auto=format&n=S7TRbFaK099mvCQ6&q=85&s=2a03ebdf00c8f95465e86060cc8e5602" alt="" width="1201" height="596" data-path="images/labs/introduction-to-amazon-auto-scaling/004.png" />
   * Instance type: Select **t2.micro**

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/S7TRbFaK099mvCQ6/images/labs/introduction-to-amazon-auto-scaling/005.png?fit=max&auto=format&n=S7TRbFaK099mvCQ6&q=85&s=be9da1595e94599e6acb6475a41417bf" alt="" width="1217" height="216" data-path="images/labs/introduction-to-amazon-auto-scaling/005.png" />

* Key pair (login):

  * Key pair name: **Don't include in the launch template**

7. Network settings:

   * Security groups: Select the **Default security group of Default VPC**
8. Keep all the settings as default.
9. Now, click on the **Create launch template** button
10. The launch template is now created.
11. Click on the **View Launch template** button.
12. The launch template is now listed.

    <img src="https://mintcdn.com/ip-cloud-architect-pathway/S7TRbFaK099mvCQ6/images/labs/introduction-to-amazon-auto-scaling/006.png?fit=max&auto=format&n=S7TRbFaK099mvCQ6&q=85&s=36b825d9e4a2a75ad5a0d65f184b5d84" alt="" width="1483" height="352" data-path="images/labs/introduction-to-amazon-auto-scaling/006.png" />

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

In this task, we are going to create an Auto Scaling group, which is a collection of EC2 instances that can automatically scale based on predefined policies and conditions.

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 Group** under **Auto Scaling**
3. Click on the **Create Auto Scaling group** button.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/S7TRbFaK099mvCQ6/images/labs/introduction-to-amazon-auto-scaling/007.png?fit=max&auto=format&n=S7TRbFaK099mvCQ6&q=85&s=d6b46e2a1162618a1a9d132d8b62f40e" alt="" width="510" height="257" data-path="images/labs/introduction-to-amazon-auto-scaling/007.png" />

4. **Step 1: Choose launch template or configuration**

   * Auto Scaling group name: Enter **whiz-ASG**
   * Launch template: Select **whizlabsLT**
   * Click on the **Next** button.
5. **Step 2: Choose instance launch options**

   * VPC: Select the **Default VPC** from the list.
   * Subnet: Select all the subnets.
   * Click on the **Next** button.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/S7TRbFaK099mvCQ6/images/labs/introduction-to-amazon-auto-scaling/008.png?fit=max&auto=format&n=S7TRbFaK099mvCQ6&q=85&s=fa970595f7a660ec904ad28a2cd5b125" alt="" width="1574" height="1174" data-path="images/labs/introduction-to-amazon-auto-scaling/008.png" />

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

   * No changes are needed on this page, click on the **Next** button.
7. **Step 4: Configure group size and scaling**

   * Under Group size – optional

     * Desired capacity: Enter **2**
     * Minimum capacity: Enter **2**
     * Maximum capacity: Enter **2**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/S7TRbFaK099mvCQ6/images/labs/introduction-to-amazon-auto-scaling/009.png?fit=max&auto=format&n=S7TRbFaK099mvCQ6&q=85&s=80e4216bf134dacdd33282a356b37a13" alt="" width="1606" height="1182" data-path="images/labs/introduction-to-amazon-auto-scaling/009.png" />

* For **Instance** **maintenance policy** – is optional, leave it as it is.
* No changes are needed, click on the **Next** button

7. **Step 5: Add notifications**

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

   * Enter tags in key-value pairs to identify your auto-scaling group.
   * Click on the **Add tag** button.
   * Key: **Name**
   * Value: **ASG-EC2**

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/S7TRbFaK099mvCQ6/images/labs/introduction-to-amazon-auto-scaling/010.png?fit=max&auto=format&n=S7TRbFaK099mvCQ6&q=85&s=89d49768b2cbb3068556120741e29ffe" alt="" width="1536" height="612" data-path="images/labs/introduction-to-amazon-auto-scaling/010.png" />
   * Click on the **Next** button
9. Now scroll down and click on the **Create Auto Scaling group** button.
10. Whiz-ASG Auto scaling is created successfully.
11. You will be redirected to the autoscaling group page, you will be able to see that two instances are launched by the autoscaling group.
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 of a minimum of 2 and a maximum of 2 instances.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/S7TRbFaK099mvCQ6/images/labs/introduction-to-amazon-auto-scaling/011.png?fit=max&auto=format&n=S7TRbFaK099mvCQ6&q=85&s=7374f148fff9b3041d236e9e0e1545b1" alt="" width="1646" height="506" data-path="images/labs/introduction-to-amazon-auto-scaling/011.png" />

#### Task 5: Test Auto Scaling Group

In this task, we are going to validate the functionality of the Auto Scaling group

1. For testing the auto-scaling policy, go to the EC2 instance list and select one of your instances.
2. Next, select an instance and click on **Instance state** and then **Stop instance.**
3. Click the **Stop** button on the pop-up window to stop your instance.
4. Once your instance is stopped (after 1-2 minutes) you can see that your stopped instance will be terminating automatically, and 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/S7TRbFaK099mvCQ6/images/labs/introduction-to-amazon-auto-scaling/012.png?fit=max&auto=format&n=S7TRbFaK099mvCQ6&q=85&s=deeaa9a4d84915ae97dcf3d47d383c4b" alt="" width="1688" height="308" data-path="images/labs/introduction-to-amazon-auto-scaling/012.png" />

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

<Tip>
  **Do you know?**

  Amazon Auto Scaling can integrate with Amazon CloudWatch, which is a monitoring and management service for AWS resources. By utilizing CloudWatch metrics, Auto Scaling can automatically adjust the capacity of EC2 instances based on predefined scaling policies. This means that as the workload increases or decreases, Auto Scaling can dynamically add or remove instances to match the demand, ensuring optimal performance and cost-efficiency.
</Tip>

#### Task 6: Validation Test

1. Once the lab steps are completed, please click on the **Check my work** button on the Right side panel.
2. This will validate the resources in the AWS account and displays whether you have completed this lab successfully or not.
3. Sample output :

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/S7TRbFaK099mvCQ6/images/labs/introduction-to-amazon-auto-scaling/013.gif?s=e343996e8b497ed165bd26c46e4c7e23" alt="" width="953" height="563" data-path="images/labs/introduction-to-amazon-auto-scaling/013.gif" />

### Completion and conclusion

1. You have successfully used the AWS management console to create a Launch Template.
2. You have configured your own details while creating an Auto Scaling Group.
3. You stopped an EC2 instance to verify a replacement instance would be created, as per the requirement.

### End lab

1. Sign out from the AWS Management Console.
2. Click on **End lab** button in the IP Lab Portal and wait till the process gets completed

## What gets checked

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

* **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.
* **Launch EC2 AMI type Amazon Linux** — Check whether the EC2 instance is launched using an Amazon AMI.
* **Launch an EC2 Instance** — Check whether an EC2 Instance is launched or not.

## Related help

* [FAQs and Troubleshooting](/aws-cp/support/faqs-and-troubleshooting)
