ALIYUN::NLB::BackendServerAttachment

更新时间:2025-02-28 02:44:51

ALIYUN::NLB::BackendServerAttachment类型用于向网络型负载均衡服务器组中添加后端服务器。

语法

{
  "Type": "ALIYUN::NLB::BackendServerAttachment",
  "Properties": {
    "ServerGroupId": String,
    "Servers": List
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

属性名称

类型

必须

允许更新

描述

约束

ServerGroupId

String

服务器组 ID。

Servers

List

后端服务器列表。

更多信息,请参见Servers属性。最多支持添加200个后端服务器。

Servers语法

"Servers": [
  {
    "ServerType": String,
    "Description": String,
    "ServerId": String,
    "ServerIp": String,
    "Port": Integer,
    "Weight": Integer
  }
]

Servers属性

属性名称

类型

必须

允许更新

描述

约束

属性名称

类型

必须

允许更新

描述

约束

ServerType

String

后端服务器类型。

取值:

  • Ecs:ECS 实例。

  • Eni:ENI 弹性网卡实例。

  • Eci:ECI 弹性容器。

  • Ip:Ip 地址。

ServerId

String

后端服务器 ID。

  • 当服务器组为 Instance 类型时,该参数为 EcsEniEci 的资源 ID。

  • 当服务器组为 Ip 类型时,该参数为 IP 地址。

Description

String

服务器描述信息。

长度限制为 2-256 个字符,可包含英文字母、数字、中文、半角逗号(,)、半角句号(.)、半角分号(;)、正斜线(/)、at(@)、下划线(_)和短划线(-)。

Port

Integer

后端服务器使用的端口。

端口范围0~65535,不填则默认传入端口值 0

当服务器组开启全端口转发后,添加后端服务器时无需指定端口(默认传入 0),NLB 将按照前端请求端口转发流量至后端服务器。您可以通过 ListServerGroups接口返回的 AnyPortEnabled 字段查询是否开启了全端口转发。

ServerIp

String

服务器 IP 地址。

当服务器组为 Ip 类型时,必须指定 IP 地址。

Weight

Integer

后端服务器的权重。

取值范围:0~100。默认值为 100。如果设置权重为 0,则不会将请求转发给该后端服务器。

返回值

Fn::GetAtt

ServerGroupId:服务器组 ID。

示例

YAML
JSON
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  ServerGroupId:
    Type: String
    Description:
      en: The ID of the server group.
    Required: true
  Servers:
    AssociationPropertyMetadata:
      Parameters:
        ServerType:
          Type: String
          Description:
            en: |-
              The type of the backend server. Valid values:
              Ecs: an ECS instance
              Eni: an ENI
              Eci: an elastic container instance
              Ip: an IP address
          AllowedValues:
            - Eci
            - Ecs
            - Eni
            - Ip
          Required: true
        Description:
          AssociationProperty: TextArea
          Type: String
          Description:
            en: ' The description of the servers. The description must be 2 to 256 characters in length, and can contain letters, digits, commas (,), periods (.), semicolons (;), forward slashes (/), at signs (@), underscores (_), and hyphens (-).'
          Required: false
          MinLength: 2
          MaxLength: 256
        ServerId:
          Type: String
          Description:
            en: The ID of the server.
          Required: true
        ServerIp:
          Type: String
          Description:
            en: The IP address of the server. If the server group type is Ip, set the ServerId parameter to an IP address.
          Required: false
        Port:
          Type: Number
          Description:
            en: 'The port used by the backend server. Valid values: 0 to 65535.'
          Required: false
          MinValue: 0
          MaxValue: 65535
        Weight:
          Type: Number
          Description:
            en: 'The weight of the backend server. Valid values: 0 to 100. Default value: 100. If the weight of a backend server is set to 0, no requests are forwarded to the backend server.'
          Required: false
          MinValue: 0
          MaxValue: 100
    AssociationProperty: List[Parameters]
    Type: Json
    Description:
      en: |-
        The backend servers that you want to add to the server group. You can specify up to
        200 servers in each call.
    Required: true
    MinLength: 1
    MaxLength: 200
Resources:
  BackendServerAttachment:
    Type: ALIYUN::NLB::BackendServerAttachment
    Properties:
      ServerGroupId:
        Ref: ServerGroupId
      Servers:
        Ref: Servers
Outputs:
  ServerGroupId:
    Description: The ID of the server group.
    Value:
      Fn::GetAtt:
        - BackendServerAttachment
        - ServerGroupId
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "ServerGroupId": {
      "Type": "String",
      "Description": {
        "en": "The ID of the server group."
      },
      "Required": true
    },
    "Servers": {
      "AssociationPropertyMetadata": {
        "Parameters": {
          "ServerType": {
            "Type": "String",
            "Description": {
              "en": "The type of the backend server. Valid values:\nEcs: an ECS instance\nEni: an ENI\nEci: an elastic container instance\nIp: an IP address"
            },
            "AllowedValues": [
              "Eci",
              "Ecs",
              "Eni",
              "Ip"
            ],
            "Required": true
          },
          "Description": {
            "AssociationProperty": "TextArea",
            "Type": "String",
            "Description": {
              "en": " The description of the servers. The description must be 2 to 256 characters in length, and can contain letters, digits, commas (,), periods (.), semicolons (;), forward slashes (/), at signs (@), underscores (_), and hyphens (-)."
            },
            "Required": false,
            "MinLength": 2,
            "MaxLength": 256
          },
          "ServerId": {
            "Type": "String",
            "Description": {
              "en": "The ID of the server."
            },
            "Required": true
          },
          "ServerIp": {
            "Type": "String",
            "Description": {
              "en": "The IP address of the server. If the server group type is Ip, set the ServerId parameter to an IP address."
            },
            "Required": false
          },
          "Port": {
            "Type": "Number",
            "Description": {
              "en": "The port used by the backend server. Valid values: 0 to 65535."
            },
            "Required": false,
            "MinValue": 0,
            "MaxValue": 65535
          },
          "Weight": {
            "Type": "Number",
            "Description": {
              "en": "The weight of the backend server. Valid values: 0 to 100. Default value: 100. If the weight of a backend server is set to 0, no requests are forwarded to the backend server."
            },
            "Required": false,
            "MinValue": 0,
            "MaxValue": 100
          }
        }
      },
      "AssociationProperty": "List[Parameters]",
      "Type": "Json",
      "Description": {
        "en": "The backend servers that you want to add to the server group. You can specify up to\n200 servers in each call."
      },
      "Required": true,
      "MinLength": 1,
      "MaxLength": 200
    }
  },
  "Resources": {
    "BackendServerAttachment": {
      "Type": "ALIYUN::NLB::BackendServerAttachment",
      "Properties": {
        "ServerGroupId": {
          "Ref": "ServerGroupId"
        },
        "Servers": {
          "Ref": "Servers"
        }
      }
    }
  },
  "Outputs": {
    "ServerGroupId": {
      "Description": "The ID of the server group.",
      "Value": {
        "Fn::GetAtt": [
          "BackendServerAttachment",
          "ServerGroupId"
        ]
      }
    }
  }
}
                        
  • 本页导读 (1)
  • 语法
  • 属性
  • Servers语法
  • Servers属性
  • 返回值
  • 示例