Search code examples
amazon-web-servicesaws-cloudformationaws-application-load-balancer

Error ListenerRule with identifier Priority 10 is currently in use on listener with 9 rules currently


I have the following (minimal test) cloudformation template:

AWSTemplateFormatVersion: 2010-09-09
Description: Test template

Resources:
  TestTargetGroupListener:
    Type: AWS::ElasticLoadBalancingV2::ListenerRule
    Properties:
      Actions:
        - Type: fixed-response
          FixedResponseConfig:
            ContentType: text/plain
            MessageBody: It works
            StatusCode: 200
      Conditions:
        - Field: host-header
          HostHeaderConfig:
            Values:
              - example.com
      ListenerArn: arn:aws:elasticloadbalancing:eu-west-1:<accountid>:listener/app/<alb name>/xxx/xxx
      Priority: 10

When I attempt to deploy this I get the message:

Resource of type 'AWS::ElasticLoadBalancingV2::ListenerRule' with identifier 'Priority '10' is currently in use (Service: ElasticLoadBalancingV2, Status Code: 400, Request ID: ..., Extended Request ID: null)' already exists." (RequestToken: ..., HandlerErrorCode: AlreadyExists)

I have checked the listener and have confirmed that there are currently 9 rules (+ the last rule).

I have also tried setting priority to 9 (in case it is 0 based) and to 11 (because I wasn't sure if "last" counted in the priorities) however I get the same message (for each priority I tried).

This is how the listener rules look like:

enter image description here

I am not sure why this is happening. I used similar templates before without any issues on the same listener.

Update: I got this to work by using Listener priority 4 which (suprisingly) worked and made the listener appear in the console as 2nd! I still don't understand how it works. I figured out I could use 4 when I attempted to create an ECS service on the AWS web console, attached to the same load listener and had the same issue when selecting listener priority. However on the web console I was able to try numbers a lot quicker than via a CF template. I still do not understand what the issue was here and I still do not know how to properly diagnose this error.

Update 2

The new AWS console now shows the rule priority in addition to the ordinal (which was the only thing shown before) so this is no longer an issue.


Solution

  • Stumbled upon the same issue. You can find the priorities by first going to EC2 management console, there select your Load balancer, open Listeners-tab and click desired listener id, it opens to a new tab. And the priorities are shown on the Rules-tab.