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

Viewed 415

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.

0 Answers
Related