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


The AWS::ElasticLoadBalancingV2::ListenerRule resource defines which requests an Elastic Load Balancing listener takes action on and the action that it takes. For more information, see Getting Started in the Elastic Load Balancing User Guide.


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 action that the listener takes when a request meets the specified condition.

Required: Yes

Type: List of Elastic Load Balancing ListenerRule Actions

Update requires: No interruption


The conditions under which a rule takes effect.

Required: Yes

Type: List of Elastic Load Balancing ListenerRule Conditions

Update requires: No interruption


The Amazon Resource Name (ARN) of the listener that the rule applies to.

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 have only one rule with a given priority.

For valid 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