Skip to content
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

Network Load Balancer listener TargetGroup cannot have weight #20163

Open
abjrcode opened this issue Jul 13, 2021 · 5 comments
Open

Network Load Balancer listener TargetGroup cannot have weight #20163

abjrcode opened this issue Jul 13, 2021 · 5 comments
Labels
bug Addresses a defect in current functionality. service/elb Issues and PRs that pertain to the elb service.

Comments

@abjrcode
Copy link

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 other comments that do not add relevant new information or questions, 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 CLI and Terraform AWS Provider Version

Terraform version: 1.0.2
AWS Provider Version: 3.49.0

Affected Resource(s)

Expected Behavior

When creating a listener for a network load balancer it shouldn't specify a weight value for the default forward action in the call to the AWS API.

Actual Behavior

An AWS error saying: You cannot specify a target group weight on load balancers of type 'network'
It has a default value of 1 for default forward action which doesn't work with NLBs

References

@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jul 13, 2021
@bill-rich bill-rich added bug Addresses a defect in current functionality. service/elb Issues and PRs that pertain to the elb service. and removed needs-triage Waiting for first response or review from a maintainer. labels Jul 16, 2021
@engineertdog
Copy link

engineertdog commented Nov 7, 2022

Even on v4.38.0, this is still an issue a year later.

Code - https://github.com/hashicorp/terraform-provider-aws/blob/main/internal/service/elbv2/listener.go#L236-L241

This is the first time looking at Go, and this project. So I'm not sure if we'd prefer to just remove the default, or change the default and the validation function.

@jre21
Copy link

jre21 commented Nov 30, 2022

@ewbankkit This issue has sat untouched for a year and a half, renders the impacted terraform resource unusable, and seems like the fix should be straightforward. Any chance you can take a look at it?

@josegonzalez
Copy link

This issue still exists. The validation code is here.

Perhaps a fix would be to allow a value of -1 - so validation.IntBetween(-1, 999), - and then omit the value here if it is a negative value?

@rob-orr
Copy link

rob-orr commented Aug 22, 2024

The valid values for weight are 0-999. When nothing is set for weight in Terraform, it defaults to 1. However, in AWS the default setting value is zero. When it is then explicitly set to zero in Terraform, the plan shows no modifications to the target_group, but the apply still fails with "You cannot specify a target group weight on load balancers of type 'network'".

We're trying to enable NLB target group stickiness, but cannot do so through Terraform because of this bug. This ticket has been open for over 3 years, and seems like it should be fixed by now!

For reference, we are using Terraform 1.9.5, and AWS provider 5.63.0.

@cdschneider
Copy link

I found that the default weight of 1 only seems to be applied when you use the forward block configuration on an aws_lb_listener resource. When I started to use the target_group_arn attribute instead, I no longer ran into this issue.

Configuration resulting in the Network Load Balancer listener TargetGroup cannot have weight error:

resource "aws_lb_listener" "this" {
  load_balancer_arn = aws_lb.nlb.arn

  default_action {
    type = "forward"

    forward {
      target_group {
        arn = aws_lb_target_group.foobar.arn
      }
    }
  }
}

Working configuration:

resource "aws_lb_listener" "this" {
  load_balancer_arn = aws_lb.nlb.arn

  default_action {
    type             = "forward"
    target_group_arn = aws_lb_target_group.foobar.arn
  }
}

Using Terraform 1.9.x and provider version 5.64.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/elb Issues and PRs that pertain to the elb service.
Projects
None yet
Development

No branches or pull requests

7 participants