Priority value for lb.addListener should be validated by CDK
See original GitHub issueCDK should provide a synth time check to make sure that the priority value for a load balancer rule is not zero.
Use Case
When creating adding many targets to listeners I set priority to zero while looping through an array:
listeners.forEach((listener, i) => {
listener.addTargets(`Target${i}`, {
pathPattern: `path-${i}`,
priority: i,
targets: [service],
port: ports[i],
protocol: elbv2.ApplicationProtocol.HTTP,
});
});
I was able to synth and diff without error. Then when I deployed I saw:
1 validation error detected: Value '0' at 'priority' failed to satisfy constraint: Member must have value greater than or equal to 1 (Service: AmazonElasticLoadBalancingV2; Status Code: 400; Error Code: ValidationError; Request ID: 79be03d3-3469-45c1-9dda-3e1e7049a6d6)
Proposed Solution
CDK should validate that priority !== 0 here.
- 👋 I may be able to implement this feature request
- ⚠️ This feature might incur a breaking change
This is a 🚀 Feature Request
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
aws-cdk/aws-elasticloadbalancingv2 module
A new listener can be added to the Load Balancer by calling addListener() . Listeners that have been added to the load balancer...
Read more >@aws-cdk/aws-elasticloadbalancingv2 - Package Manager
A new listener can be added to the Load Balancer by calling addListener() . Listeners that have been added to the load balancer...
Read more >How to correctly code AWS ALB redirection in CDK (python)
We just need to call addRedirect method on loadbalancer. Default parameters for method already has { sourcePort: 80, targetPort: 443, ...
Read more >awselasticloadbalancingv2 - Go Packages
Basic properties for an ApplicationListener. Example: import "github.com/aws/aws-cdk-go/awscdk" var lb applicationLoadBalancer listener := lb.addListener(jsii ...
Read more >aws.alb.ListenerRule - Pulumi
The priority for the rule between 1 and 50000 . Leaving it unset will automatically set the rule with next available priority after...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
priority in ALB has long been an issue in various ways. Currently I’m using a lambda to return the next available priority, but ideally I’d like to just have to not specify it, and have CDK/CF choose a none conflicting priority for me. We may be unusual in that our patterns never overlap in any way so priority doesn’t actually matter much, but maybe we’re not that unusual in such a use case.
I am using a Lambda too for this purpose and I am thinking to implement this into CDK for a while now. Good to see, that I am not alone.