terraform-provider-aws: Cannot create multiple path-pattern conditions for ALB Rules
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave “+1” or “me too” comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Terraform Version
Terraform v0.11.13
+ provider.aws v2.8.0
+ provider.template v2.1.1
Affected Resource(s)
- aws_lb_listener_rule
Terraform Configuration Files
resource "aws_lb_listener_rule" "test" {
listener_arn = "<<arn_scrubbed>>"
priority = 25
action {
type = "forward"
target_group_arn = "${aws_lb_target_group.mytarget.arn}"
}
condition {
field = "path-pattern"
values = ["/account.php", "/client.php*"]
}
condition {
field = "host-header"
values = ["dev01site.example.com"]
}
}
Expected Behavior
Created an ALB rule with a multi-condition path-pattern - this is possible to do in the console.
See screenshot:

Actual Behavior
Error: aws_lb_listener_rule.test: condition.0.values: attribute supports 1 item maximum, config has 2 declared
This is the first time I’m seeing an option in the Amazon Console GUI that I cannot perform with Terraform. Have triple checked the TF docs for aws_lb_listener_rule and it even states “A maximum of 1 can be defined.” for the Values field.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 64
- Comments: 16 (4 by maintainers)
Commits related to this issue
- IaaC :: Terraform downgrade to 0.12.1 due to https://github.com/terraform-providers/terraform-provider-aws/issues/8540 — committed to pduleba/DevOps-SL by deleted user 5 years ago
Also host-header is not supporting multiple values.
Error: aws_alb_listener_rule.alb_web_rule1: condition.0.values: attribute supports 1 item maximum, config has 2 declared.
resource “aws_alb_listener_rule” “alb_web_rule1” { listener_arn = “${aws_alb_listener.alb_web_https.arn}” priority = 1 action { type = “forward” target_group_arn = “${aws_alb_target_group.tg_web1_uat_https.arn}” } condition { field = “host-header” values = [“*uat.example.com”,“*uat-analytics.example.com”] } }
@thoo5ieb Thanks for your response. I have around 107 routes and With your solution I need to use 107 rules for https listener, which is not possible with the current ALB spec (100 rules max). With multiple values per rule config I just need to use 22 rules, which is still far from the limit. I managed to reduced the number of routes to < 100 by using wildcard prefix for some routes so your solution work for me right now. but hopefully multiple values per rule will available soon.
@sandangel If I understand correctly, the limit reaching issue you have, will be pretty much the same with different Terraform resource design constraints. Under the hood, it still does N rules for a specific AWS ALB listener. One way or other, you can reach out AWS support OR re-design (if possible) your solution to a given problem.
When I use resource
aws_lb_listener_rulewith multiple path patterns, I follow code practice below:Generally speaking, I attach multiple
aws_lb_listener_ruletoaws_lb_listener.