Listener Rules (ALB)
Attach rules to ALB listeners under lbs.<lb>.listeners.<listener>.rules
.
Key fields (per rule):
- priority — unique per listener
- action — typically forward with
target_group
key - conditions — host_header and/or path_pattern
- tags (optional)
Example:
lbs = {
default = {
subnets = ["CentralIngress.CentralIngressPublicAZ1", "CentralIngress.CentralIngressPublicAZ2"]
security_groups = ["CentralIngress.ALB"]
listeners = {
default80 = {},
default443 = {
port = "443"
protocol = "HTTPS"
certificates = ["epiccro", "mobilecro"]
default_action = {
type = "fixed-response"
fixed_response = {}
}
rules = {
hsw = {
priority = 10
action = {
target_group = "CentralIngress.hsw"
}
conditions = [{
host_header = {
values = ["epiccro.med.utah.edu"]
}
}]
},
ic = {
priority = 20
action = {
target_group = "CentralIngress.ic"
}
conditions = [{
host_header = {
values = ["mobilecro.med.utah.edu"]
}
}]
}
mobileconfig = {
priority = 100
action = {
target_group = "CentralIngress.ic_mobileconfig"
}
conditions = [{
host_header = {
values = ["haikuire.med.utah.edu"]
},
path_pattern = {
values = ["/mobileconfig"]
}
}]
}
}
}
}
}
}
Notes:
- NLB does not support listener rules; use default_action.
- For multiple conditions, include both host_header and path_pattern in the same rule.