AWS::ElasticLoadBalancingV2::ListenerRule
AWS::ElasticLoadBalancingV2::ListenerRule
资源定义 Elastic Load Balancing 侦听器对哪些请求执行操作以及所执行的操作。有关更多信息,请参阅 Elastic Load Balancing 用户指南中的入门。
语法
要在 AWS CloudFormation 模板中声明此实体,请使用以下语法:
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
属性
Actions
-
当请求满足指定的条件时,侦听器所采取的操作。
Required: Yes
Type: Elastic Load Balancing ListenerRule Actions 列表
更新要求:无需中断
Conditions
-
规则的生效条件。
Required: Yes
Type: Elastic Load Balancing ListenerRule Conditions 列表
更新要求:无需中断
ListenerArn
-
规则应用到的侦听器的 Amazon 资源名称 (ARN)。
Required: Yes
Type: String
更新要求:替换
Priority
-
规则的优先级。Elastic Load Balancing 按优先级顺序(从最低值到最高值)计算规则。如果某个请求满足其中一个规则,Elastic Load Balancing 会忽略所有后续的规则。
注意
对于一个侦听器,只能有一个规则与给定优先级关联。
有关有效值的信息,请参阅 Elastic Load Balancing API 参考版本 2015-12-01 中的 CreateRule 操作的
Priority
参数。Required: Yes
Type: Integer
更新要求:无需中断
返回值
Ref
当向 Ref
内部函数提供此资源的逻辑 ID 时,Ref
将返回规则 ARN,例如 arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/9683b2d02a6cabee
。
有关使用 Ref
功能的更多信息,请参阅参考。
示例
以下示例创建一个规则,当请求 URL 包含 /img/*
模式时,会将请求转发到 TargetGroup
目标组。
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