Search code examples
amazon-web-servicesdockeramazon-elbamazon-ecselastic-load-balancer

Amazon Application Load Balancer Host Based Routing to a specific ECS Container Service


I'm new to ECS & ALB in AWS's universe, and i'd like to know how can i point my App in the front end to a specific ECS service.

Should I give it maybe the :port or /service_name ? and if i'd like to use Host-Based Routing, and i use my own DNS subdomains. For Example :

 <service>.hostname.com , 

How can i point each service to it's corresponding one in the ECS cluster through the Application Load Balancer ?


Solution

  • With Amazon's Application Load Balancer, you associate your services with Target Groups. You can then create rules on your listeners that say which traffic to send to which Target Group. Application Load Balancer supports two different rule types: Host (eg: service1.hostname.com) and Path (eg: /service1).

    So the basic things you need to do are:

    1. Create a target group for each service
    2. Create a rule sending the hosts/paths you want to the target group
    3. Associate each service with its associated target group