ALIYUN::SLB::Rule

更新时间: 2023-04-06 13:59:45

ALIYUN::SLB::Rule类型用于为指定的HTTP或HTTPS监听添加转发规则。

语法

{
  "Type": "ALIYUN::SLB::Rule",
  "Properties": {
    "ListenerPort": Integer,
    "RuleList": List,
    "LoadBalancerId": String,
    "ListenerProtocol": String
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

ListenerPort

Integer

负载均衡实例前端使用的监听端口。

取值范围:1~65535。

RuleList

List

要添加的转发规则。

一次请求中,最多可添加10条转发规则。

每条转发规则包含以下参数:

  • RuleName

  • Domain

  • Url

  • VServerGroupId

Domain和URL两者必须指定一个,也可以同时指定。

说明

Domain和URL的组合在同一个监听内必须唯一。

LoadBalancerId

String

负载均衡实例ID。

ListenerProtocol

String

实例前端使用的协议。

RuleList语法

"RuleList": [
  {
    "Url": String,
    "Domain": String,
    "VServerGroupId": String,
    "RuleName": String
  }
]

RuleList属性

属性名称

类型

必须

允许更新

描述

约束

Url

String

访问路径

  • 长度为2~80个字符。

  • 以正斜线(/)开头,可包含字母、数字和以下特殊字符:

    -/.%?#&

Domain

String

转发规则关联的请求域名。

VServerGroupId

String

该转发规则的目标虚拟服务器组ID。

RuleName

String

转发规则名称。

长度为1~40个字符,可包含字母、数字和以下特殊字符:

-/._

同一个监听内不同规则的名称必须唯一。

返回值

Fn::GetAtt

Rules:转发规则列表。

示例

YAML示例

ROSTemplateFormatVersion: '2015-09-01'
Resources:
  Rule:
    Type: ALIYUN::SLB::Rule
    Properties:
      ListenerPort:
        Ref: ListenerPort
      RuleList:
        Fn::Split:
          - ','
          - Ref: RuleList
          - Ref: RuleList
      LoadBalancerId:
        Ref: LoadBalancerId
Parameters:
  ListenerPort:
    Type: Number
    Description: |-
      The front-end HTTPS listener port of the Server Load Balancer instance. Valid value:
      1-65535
    MaxValue: 65535
    MinValue: 1
  RuleList:
    MinLength: 1
    Type: CommaDelimitedList
    Description: The forwarding rules to add.
    MaxLength: 10
  LoadBalancerId:
    Type: String
    Description: The ID of Server Load Balancer instance.
Outputs:
  Rules:
    Description: A list of forwarding rules. Each element of rules contains "RuleId".
    Value:
      Fn::GetAtt:
        - Rule
        - Rules

JSON示例

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Resources": {
    "Rule": {
      "Type": "ALIYUN::SLB::Rule",
      "Properties": {
        "ListenerPort": {
          "Ref": "ListenerPort"
        },
        "RuleList": {
          "Fn::Split": [",", {
            "Ref": "RuleList"
          }, {
            "Ref": "RuleList"
          }]
        },
        "LoadBalancerId": {
          "Ref": "LoadBalancerId"
        }
      }
    }
  },
  "Parameters": {
    "ListenerPort": {
      "Type": "Number",
      "Description": "The front-end HTTPS listener port of the Server Load Balancer instance. Valid value:\n1-65535",
      "MaxValue": 65535,
      "MinValue": 1
    },
    "RuleList": {
      "MinLength": 1,
      "Type": "CommaDelimitedList",
      "Description": "The forwarding rules to add.",
      "MaxLength": 10
    },
    "LoadBalancerId": {
      "Type": "String",
      "Description": "The ID of Server Load Balancer instance."
    }
  },
  "Outputs": {
    "Rules": {
      "Description": "A list of forwarding rules. Each element of rules contains \"RuleId\".",
      "Value": {
        "Fn::GetAtt": ["Rule", "Rules"]
      }
    }
  }
}

阿里云首页 资源编排 相关技术圈