ALIYUN::GA::Listener类型用于创建监听。

语法

{
  "Type": "ALIYUN::GA::Listener",
  "Properties": {
    "Description": String,
    "PortRanges": List,
    "Protocol": String,
    "AcceleratorId": String,
    "Name": String,
    "ClientAffinity": String
  }
}

属性

属性名称 类型 必须 允许更新 描述 约束
Description String 监听的描述信息。
PortRanges List 监听端口。 最多支持10个监听端口。

详情请参见PortRanges属性

Protocol String 监听的网络传输协议类型。 取值:
  • tcp
  • udp
AcceleratorId String 全球加速实例ID。
Name String 监听的名称。 长度为2~128个字符。以英文字母或汉字开头,可包含英文字母、汉字、数字、下划线(_)和短划线(-)。
ClientAffinity String 客户端亲和性。 取值:
  • None(默认值):不保持客户端亲和性,即不能确保来自同一客户端的连接请求始终定向到同一终端节点。
  • SOURCE_IP:保持客户端亲和性。即客户端访问有状态的应用程序时,可以将来自同一客户端的所有请求都定向到同一终端节点,而不考虑源端口和协议。

PortRanges语法

"PortRanges": [
  {
    "FromPort": Integer,
    "ToPort": Integer
  }
]

PortRanges属性

属性名称 类型 必须 允许更新 描述 约束
FromPort Integer 用来接收请求并向终端节点进行转发的起始监听端口。
ToPort Integer 用来接收请求并向终端节点进行转发的结束监听端口。

返回值

Fn::GetAtt

ListenerId:监听ID。

示例

JSON格式

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "Description": {
      "Type": "String",
      "Description": "The description of the listener."
    },
    "PortRanges": {
      "Type": "Json",
      "Description": "",
      "MinLength": 1,
      "MaxLength": 10
    },
    "Protocol": {
      "Type": "String",
      "Description": "The network transmission protocol of the listener. Valid values:\ntcp: TCP protocol\nudp: UDP protocol",
      "AllowedValues": [
        "tcp",
        "udp"
      ]
    },
    "AcceleratorId": {
      "Type": "String",
      "Description": "The ID of the Global Accelerator instance to which the listener will be added."
    },
    "Name": {
      "Type": "String",
      "Description": "The name of the listener.\nThe name must be 2 to 128 characters in length and can contain letters, digits, underscores\n(_), and hyphens (-). It must start with a letter or Chinese character."
    },
    "ClientAffinity": {
      "Type": "String",
      "Description": "Specifies whether to enable client affinity for the listener.\nIf you do not specify the default value in the parameter, client affinity is disabled.\nWhen client affinity is disabled, the connections from a specific source (client)\nIP address are not always routed to the same endpoint.\nIf you set the value to SOURCE_IP, client affinity is enabled. When client affinity is enabled, the connections from\na specific source (client) IP address are always routed to the same endpoint.",
      "AllowedValues": [
        "NONE",
        "SOURCE_IP"
      ]
    }
  },
  "Resources": {
    "Listener": {
      "Type": "ALIYUN::GA::Listener",
      "Properties": {
        "Description": {
          "Ref": "Description"
        },
        "PortRanges": {
          "Ref": "PortRanges"
        },
        "Protocol": {
          "Ref": "Protocol"
        },
        "AcceleratorId": {
          "Ref": "AcceleratorId"
        },
        "Name": {
          "Ref": "Name"
        },
        "ClientAffinity": {
          "Ref": "ClientAffinity"
        }
      }
    }
  },
  "Outputs": {
    "ListenerId": {
      "Description": "The ID of the listener.",
      "Value": {
        "Fn::GetAtt": [
          "Listener",
          "ListenerId"
        ]
      }
    }
  }
}

YAML格式

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  Description:
    Type: String
    Description: The description of the listener.
  PortRanges:
    Type: Json
    Description: ''
    MinLength: 1
    MaxLength: 10
  Protocol:
    Type: String
    Description: |-
      The network transmission protocol of the listener. Valid values:
      tcp: TCP protocol
      udp: UDP protocol
    AllowedValues:
      - tcp
      - udp
  AcceleratorId:
    Type: String
    Description: >-
      The ID of the Global Accelerator instance to which the listener will be
      added.
  Name:
    Type: String
    Description: >-
      The name of the listener.

      The name must be 2 to 128 characters in length and can contain letters,
      digits, underscores

      (_), and hyphens (-). It must start with a letter or Chinese character.
  ClientAffinity:
    Type: String
    Description: >-
      Specifies whether to enable client affinity for the listener.

      If you do not specify the default value in the parameter, client affinity
      is disabled.

      When client affinity is disabled, the connections from a specific source
      (client)

      IP address are not always routed to the same endpoint.

      If you set the value to SOURCE_IP, client affinity is enabled. When client
      affinity is enabled, the connections from

      a specific source (client) IP address are always routed to the same
      endpoint.
    AllowedValues:
      - NONE
      - SOURCE_IP
Resources:
  Listener:
    Type: 'ALIYUN::GA::Listener'
    Properties:
      Description:
        Ref: Description
      PortRanges:
        Ref: PortRanges
      Protocol:
        Ref: Protocol
      AcceleratorId:
        Ref: AcceleratorId
      Name:
        Ref: Name
      ClientAffinity:
        Ref: ClientAffinity
Outputs:
  ListenerId:
    Description: The ID of the listener.
    Value:
      'Fn::GetAtt':
        - Listener
        - ListenerId