question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Priority value for lb.addListener should be validated by CDK

See original GitHub issue

CDK 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:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
gary-cowellcommented, Sep 27, 2019

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.

3reactions
hoegertncommented, Sep 27, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found