ALIYUN::SLB::BackendServerAttachment类型用于添加后端服务器。

语法

{
  "Type": "ALIYUN::SLB::BackendServerAttachment",
  "Properties": {
    "LoadBalancerId": String,
    "BackendServers": List,
    "BackendServerList": List,
    "BackendServerWeightList": List
  }
}

属性

属性名称 类型 必须 允许更新 描述 约束
LoadBalancerId String 负载均衡实例的唯一标识ID。
BackendServerList List 需要添加的后端服务器列表。 LoadBalancerId和BackendServerWeightList联合使用。ECS的实例ID用半角逗号(,)分隔。

当指定BackendServers时,将忽略该值。

BackendServerWeightList List 按顺序指定BackendServerList中各ECS实例的权重。 不指定该值,则BackendServerList中所有ECS实例权重都是 100;当BackendServerWeightList长度小于BackendServerList时, 则使用BackendServerWeightList中的最后一个值配置BackendServerList中剩余ECS实例的权重。
BackendServers List 需要添加的后端服务器列表。 后端服务器(ECS实例)必须在运行中才可以加入负载均衡实例。

详情请参见BackendServers属性

BackendServers语法

"BackendServers": [
  {
    "ServerId" : String,
    "Weight" : Integer,
    "Type": String,
    "ServerIp": String,
    "Description": String
  }
]

BackendServers属性

属性名称 类型 必须 允许更新 描述 约束
ServerId String ECS实例ID。 后端服务器(ECS实例)必须在运行中才可以加入负载均衡实例,每次调用最多可添加20个后端服务器。

只有性能保障型实例支持添加eni类型的后端服务器。

Weight Integer ECS实例在SLB实例中的权重。 取值范围:0~100。

默认值:100。

ServerIp String 后端服务器IP。
Type String 后端服务器类型。 取值:
  • ecs:ECS实例(默认值)。
  • eni:弹性网卡实例。
  • eci:弹性容器实例。
Description String 后端服务器描述。 长度为1~80个字符,可包含英文字母、汉字、数字、短划线(-)、正斜线(/)、英文句点(.)和下划线(_)。

返回值

Fn::GetAtt

  • BackendServers:所有加入负载均衡的后端服务器列表。
  • LoadBalancerId:负载均衡实例ID。

示例

JSON格式

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "BackendServerList": {
      "Type": "Json",
      "Description": "The comma delimited instance id list.If the property \"BackendServers\" is setting, this property will be ignored."
    },
    "LoadBalancerId": {
      "Type": "String",
      "Description": "The id of load balancer."
    },
    "BackendServerWeightList": {
      "Type": "CommaDelimitedList",
      "Description": "The comma delimited weight list. If no value specified will use 100. If the length is small than \"BackendServerList\", it will copy the last one to fill the array.If the property \"BackendServers\" is setting, this property will be ignored."
    },
    "BackendServers": {
      "Type": "Json",
      "Description": "The list of ECS instance, which will attached to load balancer."
    }
  },
  "Resources": {
    "BackendServer": {
      "Type": "ALIYUN::SLB::BackendServerAttachment",
      "Properties": {
        "BackendServerList": {
          "Ref": "BackendServerList"
        },
        "LoadBalancerId": {
          "Ref": "LoadBalancerId"
        },
        "BackendServerWeightList": {
          "Ref": "BackendServerWeightList"
        },
        "BackendServers": {
          "Ref": "BackendServers"
        }
      }
    }
  },
  "Outputs": {
    "LoadBalancerId": {
      "Description": "The id of load balancer.",
      "Value": {
        "Fn::GetAtt": [
          "BackendServer",
          "LoadBalancerId"
        ]
      }
    },
    "BackendServers": {
      "Description": "The collection of attached backend server.",
      "Value": {
        "Fn::GetAtt": [
          "BackendServer",
          "BackendServers"
        ]
      }
    }
  }
}

YAML格式

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  BackendServerList:
    Type: Json
    Description: >-
      The comma delimited instance id list.If the property "BackendServers" is
      setting, this property will be ignored.
  LoadBalancerId:
    Type: String
    Description: The id of load balancer.
  BackendServerWeightList:
    Type: CommaDelimitedList
    Description: >-
      The comma delimited weight list. If no value specified will use 100. If
      the length is small than "BackendServerList", it will copy the last one to
      fill the array.If the property "BackendServers" is setting, this property
      will be ignored.
  BackendServers:
    Type: Json
    Description: 'The list of ECS instance, which will attached to load balancer.'
Resources:
  BackendServer:
    Type: 'ALIYUN::SLB::BackendServerAttachment'
    Properties:
      BackendServerList:
        Ref: BackendServerList
      LoadBalancerId:
        Ref: LoadBalancerId
      BackendServerWeightList:
        Ref: BackendServerWeightList
      BackendServers:
        Ref: BackendServers
Outputs:
  LoadBalancerId:
    Description: The id of load balancer.
    Value:
      'Fn::GetAtt':
        - BackendServer
        - LoadBalancerId
  BackendServers:
    Description: The collection of attached backend server.
    Value:
      'Fn::GetAtt':
        - BackendServer
        - BackendServers