Open lucaspellucci opened 1 year ago
Hi @lucaspellucci
Can you share some sample code so we can run it in our environment for reproduction?
@pahud
where targetGroupOne and targetGroupTwo is of type NetworkTargetGroup, and loadBalancer is a NetworkLoadBalancer
this.loadBalancer.addListener('Listener', { defaultAction: NetworkListenerAction.weightedForward([ { targetGroup: targetGroupOne, weight: 5 }, { targetGroup: targetGroupTwo, weight: 95 }, ]), port: 8080 });
You will get a error when you compile, but if you look at NetworkLoadBalancer.addListener, it takes BaseNetworkListenerProps, which contains NetworkListenerAction that allows weightedForward to be used even though NLB doesn't support it.
Thanks, tlee9595, my code snipped is exactly the same.
Also, I want to leave this from the CloudFormation documentation here:
just confirming this still doesn't work, I was testing with different weights but same defaultAction on listener. There's no support for weightedForward as of today, it was also specified as a side note from AWS support for a different purpose, as differences with ALB.
So not sure if the documentation of NLB listener for CDK should be so explicit:
Describe the issue
There is no such thing as Weighted Target Group for NLB, at this moment this feature is exclusive for ALB.
Trying to build a NLB using more than one target group will retutn the error below:
"You cannot specify multiple target groups in a single action with a load balancer of type 'network' (Service: ElasticLoadBalancingV2, Status Code: 400"
Links
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.NetworkWeightedTargetGroup.html