0
0
AWScloud~30 mins

Listener rules and routing in AWS - Mini Project: Build & Apply

Choose your learning style9 modes available
Listener Rules and Routing in AWS Application Load Balancer
📖 Scenario: You are setting up an AWS Application Load Balancer (ALB) to route incoming web traffic to different target groups based on URL paths. This helps your website serve different content or services efficiently.
🎯 Goal: Build an AWS ALB listener configuration with rules that route requests to specific target groups based on URL path patterns.
📋 What You'll Learn
Create a listener on port 80 for the ALB
Define two target groups: tg-api and tg-web
Add listener rules to route requests with path /api/* to tg-api
Add listener rules to route requests with path /web/* to tg-web
Add a default action to forward requests to tg-web
💡 Why This Matters
🌍 Real World
Routing web traffic to different backend services based on URL paths is common in microservices and multi-tenant web applications.
💼 Career
Understanding ALB listener rules and routing is essential for cloud engineers and DevOps professionals managing scalable web infrastructure.
Progress0 / 4 steps
1
Create Target Groups
Create two target groups named tg-api and tg-web with protocol HTTP and port 80.
AWS
Need a hint?

Use aws_lb_target_group resource with name, port, protocol, and vpc_id.

2
Create ALB Listener on Port 80
Create an ALB listener resource named alb_listener that listens on port 80 for protocol HTTP and uses the ALB ARN aws_lb.main.arn.
AWS
Need a hint?

Use aws_lb_listener resource with load_balancer_arn, port, protocol, and default_action.

3
Add Listener Rule for /api/* Path
Add a listener rule resource named api_rule that matches requests with path pattern /api/* and forwards them to the target group tg-api. Use aws_lb_listener.alb_listener.arn as the listener ARN and set the rule priority to 10.
AWS
Need a hint?

Use aws_lb_listener_rule with listener_arn, priority, action, and condition for path pattern.

4
Add Listener Rule for /web/* Path
Add a listener rule resource named web_rule that matches requests with path pattern /web/* and forwards them to the target group tg-web. Use aws_lb_listener.alb_listener.arn as the listener ARN and set the rule priority to 20.
AWS
Need a hint?

Use aws_lb_listener_rule with listener_arn, priority, action, and condition for path pattern.