An Application Load Balancer (ALB) operates at the application layer (Layer 7) of the Open Systems Interconnection (OSI) model. When a request reaches the ALB, it first evaluates listener rules in priority order to determine the appropriate action. Based on this rule, it then selects a target from the designated target group. You can configure listener rules to intelligently route requests to different target groups based on application traffic content, such as the path or host.
ALBs offer great flexibility:
Target groups are essential for routing requests to your registered resources, like EC2 instances, Lambda functions, or IP addresses. They use the protocol and port you define for this routing, and a single target can be registered with multiple target groups if needed.
For our AWS Fargate tasks, we will create a target group of type IP addresses. This is because tasks launched using AWS Fargate are associated with an elastic network interface (ENI) and receive their own IP address, rather than running on an underlying Amazon EC2 instance managed by you.
1. Navigate to EC2:
EC2
2. In the EC2 Dashboard, scroll down in the left navigation panel to Load Balancing and select Target groups. Click Create target group.
3. Configure the target type:
4. Configure basic settings:
fcj-core-tg
8080
5. Configure health checks:
/health
6. Expand Advanced health check settings:
5
7. Click Next to proceed to target registration.
8. Skip target registration for now (we’ll register targets when we create ECS services) and click Create target group.
9. Verify creation: Confirm that fcj-core-tg appears in your target groups list.
1. In the EC2 Dashboard, under Load Balancing, select Load Balancers and click Create load balancer.
2. Select Application Load Balancer and click Create.
3. Configure basic settings:
fcj-alb
4. Configure network mapping:
5. Configure security:
6. Configure listeners and routing:
7. Click Create load balancer.
8. Verify creation: Wait for the load balancer to become “Active” and note the DNS name for later use.
You now have:
We’ll configure additional listener rules for the admin application in the later section.