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

AWS::ElasticLoadBalancingV2::ListenerRule

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.

Syntax

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

JSON

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

YAML

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

Properties

Actions

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

Conditions

The conditions under which the rule takes effect.

Required: Yes

Type: List of Elastic Load Balancing V2 Conditions

Update requires: No interruption

ListenerArn

The Amazon Resource Name (ARN) of the listener.

Required: Yes

Type: String

Update requires: Replacement

Priority

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.

Note

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

Ref

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.

Example

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

JSON

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

YAML

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