Overview
Lab details
- This lab walks you through the steps to create and configure an Amazon EC2 Auto Scaling with Launch templates using the AWS Management Console.
- 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.
- You will create a web page and publish it.
- Duration: 1 hour 30 minutes
- AWS Region: US East (N. Virginia) us-east-1
Architecture diagram

Task details
- Sign into AWS Management Console
- Create a Security Group for the load balancer
- Create a Security Group for Launch template
- Create a Key Pair for the Launch template
- Creating a Launch template
- Creating the Load Balancer
- Create an Auto Scaling Group
- SSH into EC2 Instance
- Install the stress
- Test Auto Scaling Group
- Validation of the lab
Launching the lab environment
- To launch the lab environment, Click on the Launch lab button.
- Please wait until the cloud environment is provisioned. It will take less than a minute to provision.
- Once the Lab is started, you will be provided with IAM user name, Password, Access Key, and Secret Access Key.
You can only start one lab at any given time
Lab guide
Lab steps
Task 1: Sign in to AWS Management Console
- Click on the Open console button, and you will get redirected to AWS Console in a new browser tab.
- 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
- 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 the Load balancer
- Make sure you are in the N.Virginia Region.
- Navigate to EC2 by clicking on the Services menu available under the Compute section.
- On the left panel menu, select the Security Groups under the Network & Security section.
- Click on the Create security group button.

- We are going to create a Security group for the Launch template with port 80 number enabled.
- Security group name: Enter Load-balancer-SG
- Description: Enter Security group for Load balancer
- VPC: Select Default VPC

-
Click on the Add rule button under Inbound rules.
- Type : Select HTTP
- Source : Select Anywhere-IPv4
-
In the textbox add 0.0.0.0/0

- Leave everything as default and click on the Create security group button.
Task 3: Create a Security Group for Launch template
- Click on the Create security group button.
-
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

-
Click on the Add rule button under Inbound rules.
- Here we will add SSH from the open internet and HTTP from the security group of a Load Balancer.
- Type : Select SSH
- Source : Select Anywhere-IPv4
- In the textbox add 0.0.0.0/0
- Click on the Add rule button to add HTTP
- Type : Select HTTP
- Source : Select Custom
- In the textbox type, Load-balancer-SG, select it.

- Leave everything as default and click on the Create security group button.
Task 4: Create a Key Pair for the Launch template
- In the left navigation pane (scroll down) within Network & Security, click on the Key Pairs.
- To create a new key pair, click on the Create key pair button.

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

- Key pair will be created.
Task 5: Creating a Launch template
- In the left navigation pane (scroll down) within Instances, click on the Launch templates
- Click on the Create launch template button.

- Under Launch template name and description section:
- Launch template name: Enter whizlabsLC
- Template version description: Enter Launch template for whizdemo
- Leave other options as default.

- Under Launch template contents:
- Select Amazon Linux from the Quick Start
-
Amazon machine image (AMI): Select Amazon Linux 2023 kernel-6.1 AMI

-
Under Instance type:
- Select t2.micro from the below list.

- Key pair (Login): Select WhizKeyPair

- Subnet: Choose any subnet from the list.
- Security groups: Select Launch-template-SG from the list

- Leave all other options as default.
- Expand the option of Advanced details, Go to the User data, and paste the below script.
- To create, click on the Create launch template button. Upon successful creation, it will create a Launch template.
Task 6: Create Target group and The Load Balancer
(I) Create Target group :- In the EC2 console, navigate to Target Groups from the left navigation panel.
- Click on Create Target Group button.

- Target Type: Select Instances
- Name: Enter web-server-TG
- Protocol: Choose HTTP
- Port : Enter 80

- Note: The target group is used to route requests to one or more registered targets
- Health check:
- Protocol: Select HTTP
- Path: Enter /health.html
- Note: The load balancer periodically sends pings, attempts connections, or sends requests to test the EC2 instances. These tests are called health checks.

- Click on the Next button.
- Leave this page as default and click on Create target group button.
- In the EC2 console, navigate to Load balancers in the left-side panel.
- Click on Create load balancer button at the top-left to create a new load balancer for our web servers.

- On the next screen, choose Create button under Application Load Balancer since we are testing the high availability of the web application.
- In Basic configuration:
- Name: Enter Web-server-LB
- Scheme: Select Internet-facing
- IP address type: Choose IPv4

-
Availability Zones
- VPC: Choose Default
- Availability Zones : Select us-east-1a and us-east-1b.
-
Security Groups:
- Remove the default one and choose Load-balancer-SG

We must specify the availability zones in which the load balancer needs to be enabled, making it route traffic only two targets launched in those availability zones. You must include subnets from a minimum of two Availability zones to make our Load balancer Highly-Available.
- In the listener part select the Target group that you have created earlier. if it is not visible click on refresh button.

- Click on Create Load Balancer button.
- You have successfully created the Application Load balancer.

- Wait for 2 to 3 minutes for the load balancer to become Active.
Task 7: Create an Auto Scaling Group
- 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.
- Go to the left menu under EC2 and choose Auto Scaling Groups under Auto Scaling.
- Click on the Create Auto Scaling group button.

- Step 1 : Choose launch template
- Auto Scaling group name : Enter Whiz-ASG
- Select the Launch template whizlabsLC from the list and click on the Next button.

- Step 2: Choose instance launch options
- VPC: Select the Default VPC from the list.
- Subnet: Select Subnet of us-east-1a and us-east-1b
- Click on the Next button.

-
Step 3 : Integrate with other services
- Load balancing - optional: Attach to an existing load balancer
- Attach to an existing load balancer: Choose from your load balancer target groups
- Existing load balancer target groups: web-server-TG

-
Health check - optional:
- Health check type: EC2 (default) and Check the Turn on Elastic Load Balancing health checks checkbox.
- Health check grace period: 180 seconds
- Click on the Next button.
-
Step 4: Configure group size and scaling
-
Under Group size
- Desired capacity : Enter 2 Under Scaling, set the following limits
- Minimum capacity : Enter 1
- Maximum capacity : Enter 2
-
Automatic scaling
- Select Target tracking scaling policy
- Scaling policy name: Target tracking policy
- Metric value: Average CPU Utilization
- Target value:Enter 30
- Instance need: 200 seconds warm up before including in metric
-
Under Instance scale-in protection
- No changes are needed, click on the Next button.
-
Under Group size
-
Step 5: Add notifications
- No changes are needed in this page, click on the Next button.
-
Step 6: Add tags
-
Enter tags in key-value pairs to identify your auto scaling group instances.
- Key: Enter Name
- Value: Enter Whiz
-
Enter tags in key-value pairs to identify your auto scaling group instances.

- Click on the Next button.
- Now Review, scrolldown and click on the Create Auto Scalling Group button.
- You will be redirected to the autoscaling group page, you will be able to see that one instance is launched by the autoscaling group.
- Now go to the EC2 instances list. You will see that there are one 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.
- You have successfully created an autoscaling group with a policy to a minimum of 1 and a maximum of 2 instances.
Task 8: SSH into EC2 Instance
- Please follow the steps in SSH into EC2 Instance.
Task 9: Install the stress
-
Switch to root user:
- Now run the updates using the following command:
-
Once completed, let’s install and run an stress
-
Install the required packages and libraries
-
Install the required packages and libraries
Task 10: Test Auto Scaling Group and Elastic Load Balancer
- For testing the auto-scaling policy, go to the EC2 instance list. You will see more new instances are getting launched.
-
That we can see in Auto scaling page also. Capacity count will be increased.
Note: It will take 10-15 min to launch all instances

- Copy the DNS of your load balancer, and paste it into the browser.

- The load balancer will now try to route to a new instance every time.

Task 11: Validation of the Lab
- Once the lab steps are completed, please click on the Check my work button on the right-side panel.
- This will validate the resources in the AWS account and displays whether you have completed this lab successfully or not.
- Sample output :

Completion and conclusion
- You have created a security group and key pair for the Launch template.
- You have created a Launch template and Auto Scaling.
- You have created an Application load balancer with Target group.
- You have tested the autoscaling by stressing the load on the first EC2 instance.
End lab
- Sign out of the AWS Account.
- You have successfully completed the lab.
- Once you have completed the steps, click on End lab in the IP Lab Portal.
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 ELB Target Group — Check if given type of Load Balancer is created or not.
- Create a Application Load Balancer — Check if given type of Load Balancer is created or not.
- Invoke Load Balancer DNS — Check whether the Elastic Load Balancer DNS URL is accessible from the internet or not.
- Create Amazon EC2 Auto Scaling Group — Check whether an Auto Scaling Group is created or not.