Multiple Target Groups
Configure an ALB to distribute traffic across multiple target groups.
module "multi_tg_alb" {
source = "registry.patterneddesigns.ca/patterneddesigns/alb/aws"
version = "3.0.0"
name = "multi-tg-alb"
vpc_id = module.vpc.vpc_id
subnets = module.vpc.public_subnets
target_groups = [
{
name = "api-targets"
port = 8080
protocol = "HTTP"
target_type = "instance"
health_check = {
path = "/health"
interval = 30
}
},
{
name = "web-targets"
port = 80
protocol = "HTTP"
target_type = "instance"
health_check = {
path = "/"
interval = 30
}
}
]
}
Key Points
- Define multiple target groups with different configurations
- Each target group can have its own health check settings
- Use listener rules to route traffic to appropriate target groups