When I inherited a project, I discovered an application load balancer with a HTTPS Listener that was set up before I began using CDK.
This listener currently has 13 rules in place that route requests based on hostname to different fargate instances, with the last rule acting as a fallback option.
Now, I need to add new rules using CDK before the fallback rules. Since new rules will be added for new fargate services in the future, this process needs to be dynamic.
How can I insert new rules into an existing listener and determine the priority of a specific rule (in this case, the fallback rule) to use as a starting point for priority calculation?
Alternatively, is it feasible to simply add one rule after another with each having a priority of 1, causing the priorities of the existing rules to increment by 1 each time?
I managed to retrieve the existing listener using the following code snippet, but I am unsure how to access its rules:
const httpsListener = elbv2.ApplicationListener.fromLookup(
this,
"ALBListenerHTTPS", {
listenerArn: "my:aws:alb:listener:arn",
}
);