This lab teaches how to set up an Auto Scaling infrastructure in AWS, including creating an AMI, configuring a load balancer, and implementing an Auto Scaling group. It demonstrates dynamic resource scaling based on demand to ensure application availability and efficient traffic distribution. The lab also tests scaling by increasing load and verifying load balancer functionality.
Summary:
Step 1: Create an AMI from Web Server 1
Step 2: Create a Load Balancer
Step 3: Create a Launch Template
Step 4: Create an Auto Scaling Group
Step 5: Verify Load Balancer Functionality
Step 6: Test Auto Scaling
Step 7: Terminate Web Server 1
Step 1: Create an AMI from Web Server 1
Go to EC2 Dashboard:
- Search for EC2 in the AWS Management Console.
Select Instance:
- In the Instances section, find Web Server 1 (ensure it's in the Running state).
Create Image:
- Select Web Server 1.
- Choose Actions > Image and templates > Create image.
- Set Image name: Web Server AMI.
- Optional: Add Image description: Lab AMI for Web Server.
- Click Create image.
Note AMI ID:
- Copy the AMI ID for use when launching the Auto Scaling group later.
Step 2: Create a Load Balancer
Navigate to Load Balancers:
- In the EC2 Dashboard, go to Load Balancers under the Load Balancing section.
Create Load Balancer:
- Click Create load balancer.
- Choose Application Load Balancer.
- Set Load balancer name: LabELB.
Network Configuration:
- Select Lab VPC.
- Map to Public Subnet 1 and Public Subnet 2 for availability zones.
Security Group:
- Remove the default security group.
- Select Web Security Group (preconfigured for HTTP access).
Create Target Group:
- Click Create target group (opens a new tab).
- Choose Instances as the target type.
- Set Target group name: lab-target-group.
- Click Next and Create target group.
Assign Target Group to Load Balancer:
- Return to the Load Balancer tab and Refresh the target groups.
- Select lab-target-group for the Forward to action.
Create Load Balancer:
- Click Create load balancer and copy the DNS name.
Step 3: Create a Launch Template
Access Launch Templates:
- In the EC2 Dashboard, go to Launch Templates.
Create Launch Template:
- Set Launch template name: lab-app-launch-template.
- Add a Description: A web server for the load test app.
- Check the box for Auto Scaling guidance.
AMI and Instance Type:
- Choose the My AMIs tab and select Web Server AMI.
- Set the Instance type to t3.micro.
Security Group:
- Select Web Security Group.
Create Template:
- Click Create launch template.
Step 4: Create an Auto Scaling Group
Create Auto Scaling Group:
- Select lab-app-launch-template from the launch template list.
- Choose Actions > Create Auto Scaling group.
- Set Auto Scaling group name: Lab Auto Scaling Group.
Network Configuration:
- Select Lab VPC.
- Assign Private Subnet 1 and Private Subnet 2.
Attach Load Balancer:
- Choose Attach to an existing load balancer.
- Select lab-target-group | HTTP.
Health Check:
- Set Health check type to ELB.
Group Size and Scaling Policy:
- Set Desired capacity: 2.
- Set Minimum capacity: 2.
- Set Maximum capacity: 4.
- Enable Target tracking scaling policy for Average CPU utilization and set the target to 50%.
Tags:
- Add a Tag:
- Key: Name,
- Value: Lab Instance.
Create Auto Scaling Group:
- Finish by clicking Create Auto Scaling group.
Step 5: Verify Load Balancer Functionality
Check Instances:
- Go to Instances in the EC2 Dashboard.
- Ensure two Lab Instances are running.
Check Target Health:
- In Load Balancing > Target Groups, find lab-target-group.
- Verify that both Lab Instances show a Healthy status.
Access Application:
- Use the load balancer DNS name to check if the Load Test app is running.
Step 6: Test Auto Scaling
Access CloudWatch:
- In the AWS Console, search for CloudWatch.
Check Alarms:
- In Alarms, locate the AlarmHigh (CPU utilization > 50%).
- Ensure the state is OK.
Generate Load:
- Open the Load Test tab from the web application.
- Trigger high CPU load by selecting Load Test.
Monitor Scaling:
- In CloudWatch, check the AlarmHigh status, which should change to In alarm.
- Auto Scaling should add instances as CPU load increases.
Top comments (0)