External Load Balancer and Auto Scaling
Web Tier AMI
- Navigate to Instances on the left-hand side of the EC2 dashboard.
- Select the web tier instance we created.
- Under Actions, select Image and templates.
- Click Create Image.
- Give the image a name and description, then click Create image.
- To monitor the status of the image creation:
- Click AMIs under Images on the left-hand navigation panel of the EC2 dashboard.
Target Group
While the AMI is being created, we can create a target group for our load balancer.
- Navigate to Target Groups under Load Balancing on the left-hand side.
- Click on Create Target Group.
- Select Instances as the target type.
- Give it a name.
- Set the protocol to HTTP and port to 80.
- Select the VPC we’ve been using.
- Change the health check path to
/health
. - Click Next.
- Skip target registration and create the target group.
Internet-Facing Load Balancer
- Navigate to Load Balancers under Load Balancing.
- Click Create Load Balancer.
- Choose Application Load Balancer.
- Give the load balancer a name.
- Select Internet-facing.
- Choose the correct VPC and public subnets.
- Select the security group created for this ALB.
- Set HTTP traffic on port 80.
- Forward traffic to the target group created earlier.
- Click Create Load Balancer.
Launch Template
Before configuring Auto Scaling, create a Launch Template with the AMI created earlier.
- Navigate to Launch Template under Instances.
- Click Create Launch Template.
- Name the Launch Template.
- Under Application and OS Images, select the app tier AMI created earlier.
- Choose Instance Type as
t2.micro
. - Do not include a Key pair and Network Settings.
- Set the correct security group for the web tier.
- Under Advanced details, use the same IAM instance profile used for EC2 instances.
- Click Create Launch Template.
Auto Scaling
- Navigate to Auto Scaling Groups under Auto Scaling.
- Click Create Auto Scaling Group.
- Give it a name.
- Select the Launch Template created earlier.
- Click Next.
- Set VPC and public subnets for the web tier.
- Attach the Auto Scaling Group to the Load Balancer’s target group.
- Set desired, minimum, and maximum capacity to 2.
- Click Skip to review, then Create Auto Scaling Group.
Web Application Deployment
After completing these steps, our WebApp is fully set up and ready to handle traffic efficiently!