Back to Blog
·2 min read

Application Load Balancer to ECS Full Walkthrough

Learn how to create an application load balancer to route traffic to specific containers based on path or host-based routing.

J

Jerrod

Cavanex

Learn how to create an application load balancer to route traffic to specific containers based on path or host-based routing.

Application Load Balancers (ALB) are a powerful way to distribute traffic across multiple ECS tasks. This guide walks you through setting up an ALB with ECS.

Prerequisites

  • An existing VPC with public and private subnets
  • An ECS cluster
  • A container image in ECR or Docker Hub

Step 1: Create Target Group

  1. Navigate to EC2 > Target Groups
  2. Click "Create target group"
  3. Choose "IP addresses" as target type (for Fargate) or "Instance" (for EC2)
  4. Configure health check settings
  5. Create the target group

Step 2: Create Application Load Balancer

  1. Navigate to EC2 > Load Balancers
  2. Click "Create Load Balancer"
  3. Select "Application Load Balancer"
  4. Configure listeners (HTTP on port 80, HTTPS on port 443)
  5. Select your VPC and public subnets
  6. Configure security groups
  7. Add your target group

Step 3: Create ECS Service

  1. Navigate to your ECS cluster
  2. Create a new service
  3. Select your task definition
  4. Under "Load balancing", select "Application Load Balancer"
  5. Choose your ALB and target group
  6. Configure the container port mapping

Path-Based Routing

To route traffic based on URL paths, create listener rules on your ALB that forward requests to different target groups based on the path pattern.

DevOpsAWSCloud

Need help with your project?

Book a free consultation to discuss your infrastructure needs.

Book a Call