-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lb_listener_rule target group support in 2.65 #13636
Comments
Hi @jmgreg31 👋 What version of Terraform CLI are you using ( |
@bflad I am using the latest version - apologies I updated the original comment
|
I believe the attempted working around is facing this issue: #636 However none of the solutions mentioned with random naming would solve for this use case as we would in fact need to destroy the resource. |
#12574 (comment) explains that this is an API issue with
I suppose the terraform provider would need to special-case the single- |
Best workaround might be to use separate resources for the two structural cases: resource "aws_lb_listener_rule" "http-forward" {
count = (var.second_target_group_arn == null) ? 1 : 0
listener_arn = var.alb_listener_arn
priority = var.alb_priority
condition {
host_header {
values = [var.server_name]
}
}
action {
type = "forward"
target_group_arn = var.first_target_group_arn
}
}
resource "aws_lb_listener_rule" "http-forward-weighted" {
count = (var.second_target_group_arn == null) ? 0 : 1
listener_arn = var.alb_listener_arn
priority = var.alb_priority
condition {
host_header {
values = [var.server_name]
}
}
action {
type = "forward"
forward {
target_group {
arn = var.first_target_group_arn
weight = var.first_target_group_weight
}
target_group {
arn = var.second_target_group_arn
weight = var.second_target_group_weight
}
}
}
} |
Having same issue in v0.12.29
|
Same issue on TF 0.14.4. |
I hit this exact error while trying trying out a
When the last ❯ tf apply
Error: List shorter than MinItems
on .terraform/modules/mo-module/main.tf line 173, in resource "aws_lb_listener" "this":
173: target_group {
Attribute supports 2 item minimum, config has 1 declared But when the # module.my-module.aws_lb_listener.this will be created
+ resource "aws_lb_listener" "this" {
+ arn = (known after apply)
+ certificate_arn = "arn:aws:acm:..."
<...>
+ ssl_policy = "ELBSecurityPolicy-FS-1-2-Res-2020-10"
+ default_action {
+ order = (known after apply)
+ type = "forward"
+ forward {
+ target_group {
+ arn = "Bar"
+ weight = 80
}
+ target_group {
+ arn = "Foo"
+ weight = 80
}
}
}
} And when the first # module.my-module.aws_lb_listener.this will be created
+ resource "aws_lb_listener" "this" {
+ arn = (known after apply)
<...>
+ ssl_policy = "ELBSecurityPolicy-FS-1-2-Res-2020-10"
+ default_action {
+ order = (known after apply)
+ type = "forward"
+ forward {
+ target_group {
+ arn = (known after apply)
+ weight = 1
}
}
}
} So you can get around the "need a minimum of two" error if you do it I am UTD: ❯ tf -version
Terraform v0.14.5
+ provider registry.terraform.io/hashicorp/aws v3.25.0 And it looks like i spoke too soon! The error, when using # module.my-module.aws_lb_listener.this will be created
+ resource "aws_lb_listener" "this" {
+ arn = (known after apply)
<...>
+ default_action {
+ order = (known after apply)
+ type = "forward"
+ forward {
+ target_group {
+ arn = (known after apply)
+ weight = 1
}
}
}
}
<...>
Plan: 10 to add, 2 to change, 2 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
<...>
module.bastion.aws_instance.bastion: Still creating... [1m10s elapsed]
module.bastion.aws_instance.bastion: Creation complete after 1m11s [id=i-DeadBeefBabe12345]
Error: List shorter than MinItems
on .terraform/modules/my-module/main.tf line 153, in resource "aws_lb_listener" "this":
153: forward {
Attribute supports 2 item minimum, config has 1 declared
So no. No work around :(. |
Also experiencing this issue in terraform verison
Getting the error
|
Facing the same issue. Terraform Version is 0.13.5 I am trying to create the default ALB listener rule.
Getting the same error |
Why should I have two target groups in my ALB listener rule? I just don't get it.
|
In this comment I got a explanation: #12574 (comment) |
But what if you need to create a stickiness block? Or if the existing default has an invalid duration? See #15144 |
Trying to do the same operation as @trentondyck is doing. How do you add stickiness block for a listener rule with a single target group?
|
The same issue.
Interestingly, the |
This is still an issue, and not an AWS API limitation as this point. |
Same issue with version:
i am able to route to a single target group with target_group_arn but how should i add a stickiness block? |
I am working on this as part of my 100 days of terraform contributions challenge. PR arriving soon. |
This functionality has been released in v5.24.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Community Note
Terraform Version
Affected Resource(s)
Terraform Configuration Files
Debug Output
Expected Behavior
This pattern works fine if you are using multiple target groups blocks. Per the documentation, I would expect this to work with a single target group block as well
Actual Behavior
error
Steps to Reproduce
terraform apply
Important Factoids
Found a workaround, however, if you re-apply a listener rule with fewer target groups it will throw an error
Attempted workaround:
Wondering if the use case of dynamic number of target groups is just not yet supported?
The text was updated successfully, but these errors were encountered: