Open abjrcode opened 3 years ago
Even on v4.38.0
, this is still an issue a year later.
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.
@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?
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.
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.
Community Note
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 of1
for default forward action which doesn't work with NLBsReferences