AWS CloudFormation
User Guide (API Version 2010-05-15)


The AWS::ElasticLoadBalancingV2::ListenerRule resource defines the rules for a listener. For more information, see Listener Rules for Your Application Load Balancer in the User Guide for Application Load Balancers.


To declare this entity in your AWS CloudFormation template, use the following syntax:


{ "Type" : "AWS::ElasticLoadBalancingV2::ListenerRule", "Properties" : { "Actions" : [ Actions, ... ], "Conditions" : [ Conditions, ... ], "ListenerArn" : String, "Priority" : Integer } }


Type: AWS::ElasticLoadBalancingV2::ListenerRule Properties: Actions: - Actions Conditions: - Conditions ListenerArn: String Priority: Integer



The actions that the listener takes when the specified conditions are met.

Required: Yes

Type: List of Elastic Load Balancing V2 Actions

Update requires: No interruption


The conditions under which the rule takes effect.

Required: Yes

Type: List of Elastic Load Balancing V2 Conditions

Update requires: No interruption


The Amazon Resource Name (ARN) of the listener.

Required: Yes

Type: String

Update requires: Replacement


The priority for the rule. Elastic Load Balancing evaluates rules in priority order, from the lowest value to the highest value. If a request satisfies a rule, Elastic Load Balancing ignores all subsequent rules.


A listener can't have multiple rules with the same priority.

For the valid range of values, see the Priority parameter for the CreateRule action in the Elastic Load Balancing API Reference version 2015-12-01.

Required: Yes

Type: Integer

Update requires: No interruption

Return Value


When the logical ID of this resource is provided to the Ref intrinsic function, Ref returns the rule's ARN, such as arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/9683b2d02a6cabee.

For more information about using the Ref function, see Ref.


The following example creates a rule that forwards requests to the TargetGroup target group if the request URL contains the /img/* pattern.


"ListenerRule": { "Type": "AWS::ElasticLoadBalancingV2::ListenerRule", "Properties": { "Actions": [{ "Type": "forward", "TargetGroupArn": { "Ref": "TargetGroup" } }], "Conditions": [{ "Field": "path-pattern", "Values": [ "/img/*" ] }], "ListenerArn": { "Ref": "Listener" }, "Priority": 1 } }


ListenerRule: Type: AWS::ElasticLoadBalancingV2::ListenerRule Properties: Actions: - Type: forward TargetGroupArn: Ref: TargetGroup Conditions: - Field: path-pattern Values: - "/img/*" ListenerArn: Ref: Listener Priority: 1