ALIYUN::ESS::ServerGroupAttachment

ALIYUN::ESS::ServerGroupAttachment类型用于从伸缩组添加一个或多个负载均衡服务器组,支持的服务器组类型包括:应用型负载均衡ALB (Application Load Balancer)、网络型负载均衡NLB (Network Load Balancer)。

语法

{
  "Type": "ALIYUN::ESS::ServerGroupAttachment",
  "Properties": {
    "ServerGroups": List,
    "ScalingGroupId": String,
    "ForceAttach": Boolean
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

ServerGroups

List

服务器组的相关信息集合。

最多添加100个服务器组。更多信息,请参见ServerGroups属性

ScalingGroupId

String

伸缩组ID。

ForceAttach

Boolean

是否将当前伸缩组内的ECS实例添加到新增的服务器组。

取值:

  • true:添加。

  • false(默认值):不添加。

ServerGroups语法

"ServerGroups": [
  {
    "Type": String,
    "Port": Integer,
    "ServerGroupId": String,
    "Weight": Integer
  }
]

ServerGroups属性

属性名称

类型

必须

允许更新

描述

约束

Type

String

服务器组类型。

取值:

  • ALB:应用型负载均衡ALB(Application Load Balancer)。

  • NLB:网络型负载均衡NLB(Network Load Balancer)。

Port

Integer

弹性伸缩将ECS实例添加到服务器组后,ECS实例使用的端口号。

取值范围:0~65535。

ServerGroupId

String

服务器组ID。

Weight

Integer

弹性伸缩将ECS实例添加到服务器组后,ECS实例作为后端服务器的权重。

权重越高,ECS实例将被分配到越多的访问请求。如果权重为0,则ECS实例不会收到访问请求。取值范围:0~100。

返回值

Fn::GetAtt

ScalingActivityId:添加服务器组,并将伸缩组内的ECS实例添加到该服务器组时,伸缩活动的ID。

说明

仅当ForceAttach取值为true时,返回该参数。

示例

YAML格式

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  ServerGroups:
    AssociationPropertyMetadata:
      Parameter:
        AssociationPropertyMetadata:
          Parameters:
            Type:
              Type: String
              Description:
                en: |-
                  The type of backend server group.
                  Valid values:
                  ALB
                  NLB
              AllowedValues:
                - ALB
                - NLB
            Port:
              Type: Number
              Description:
                en: |-
                  The port number used by an ECS instance in the scaling group after Auto Scaling adds the ECS instance to backend server group.
                  ALB server group port range [1,65535], NLB server group port range [0,65535].
              MinValue: 0
              MaxValue: 65535
            ServerGroupId:
              Type: String
              Description:
                en: The ID of backend server group.
            Weight:
              Type: Number
              Description:
                en: |-
                  The weight of an ECS instance in the scaling group as a backend server after Auto Scaling adds the ECS instance to backend server group. Valid values: 0 to 100.
                  If you increase the weight of an ECS instance in a backend server group, the number of access requests that are forwarded to the ECS instance increases. If you set the Weight parameter for an ECS instance in a backend server group to 0, no access requests are forwarded to the ECS instance.
              MinValue: 0
              MaxValue: 100
        Type: Json
    AssociationProperty: List[Parameter]
    Type: Json
    Description:
      en: A collection of information about server groups.
    MinLength: 1
    MaxLength: 100
    Default:
      - Type: ALB
        Port: 80
        ServerGroupId: sgp-5yc3bd9lfyh*****
        Weight: 100
  ScalingGroupId:
    Type: String
    Description:
      en: The ID of the scaling group.
    Default: asg-bp1fo0dbtsbmqa9h****
  ForceAttach:
    Type: Boolean
    Description:
      en: |-
        Specifies whether to add the Elastic Compute Service (ECS) instances in the scaling group to the backend server group of the newly attached SLB instance. Valid values:
        true
        false
        Default value: false.
    Default: true
Resources:
  ServerGroupAttachment:
    Type: ALIYUN::ESS::ServerGroupAttachment
    Properties:
      ServerGroups:
        Ref: ServerGroups
      ScalingGroupId:
        Ref: ScalingGroupId
      ForceAttach:
        Ref: ForceAttach
Outputs:
  ScalingActivityId:
    Description: |-
      The ID of the scaling activity during which one or more SLB instances are attached to the scaling group and the ECS instances in the scaling group are added to the backend server groups of the SLB instances.
      Note This parameter is returned only after you set the ForceAttach parameter to true.
    Value:
      Fn::GetAtt:
        - ServerGroupAttachment
        - ScalingActivityId

JSON格式

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "ServerGroups": {
      "AssociationPropertyMetadata": {
        "Parameter": {
          "AssociationPropertyMetadata": {
            "Parameters": {
              "Type": {
                "Type": "String",
                "Description": {
                  "en": "The type of backend server group.\nValid values:\nALB\nNLB"
                },
                "AllowedValues": [
                  "ALB",
                  "NLB"
                ]
              },
              "Port": {
                "Type": "Number",
                "Description": {
                  "en": "The port number used by an ECS instance in the scaling group after Auto Scaling adds the ECS instance to backend server group.\nALB server group port range [1,65535], NLB server group port range [0,65535]."
                },
                "MinValue": 0,
                "MaxValue": 65535
              },
              "ServerGroupId": {
                "Type": "String",
                "Description": {
                  "en": "The ID of backend server group."
                }
              },
              "Weight": {
                "Type": "Number",
                "Description": {
                  "en": "The weight of an ECS instance in the scaling group as a backend server after Auto Scaling adds the ECS instance to backend server group. Valid values: 0 to 100.\nIf you increase the weight of an ECS instance in a backend server group, the number of access requests that are forwarded to the ECS instance increases. If you set the Weight parameter for an ECS instance in a backend server group to 0, no access requests are forwarded to the ECS instance."
                },
                "MinValue": 0,
                "MaxValue": 100
              }
            }
          },
          "Type": "Json"
        }
      },
      "AssociationProperty": "List[Parameter]",
      "Type": "Json",
      "Description": {
        "en": "A collection of information about server groups."
      },
      "MinLength": 1,
      "MaxLength": 100,
      "Default": [
        {
          "Type": "ALB",
          "Port": 80,
          "ServerGroupId": "sgp-5yc3bd9lfyh*****",
          "Weight": 100
        }
      ]
    },
    "ScalingGroupId": {
      "Type": "String",
      "Description": {
        "en": "The ID of the scaling group."
      },
      "Default": "asg-bp1fo0dbtsbmqa9h****"
    },
    "ForceAttach": {
      "Type": "Boolean",
      "Description": {
        "en": "Specifies whether to add the Elastic Compute Service (ECS) instances in the scaling group to the backend server group of the newly attached SLB instance. Valid values:\ntrue\nfalse\nDefault value: false."
      },
      "Default": true
    }
  },
  "Resources": {
    "ServerGroupAttachment": {
      "Type": "ALIYUN::ESS::ServerGroupAttachment",
      "Properties": {
        "ServerGroups": {
          "Ref": "ServerGroups"
        },
        "ScalingGroupId": {
          "Ref": "ScalingGroupId"
        },
        "ForceAttach": {
          "Ref": "ForceAttach"
        }
      }
    }
  },
  "Outputs": {
    "ScalingActivityId": {
      "Description": "The ID of the scaling activity during which one or more SLB instances are attached to the scaling group and the ECS instances in the scaling group are added to the backend server groups of the SLB instances.\nNote This parameter is returned only after you set the ForceAttach parameter to true.",
      "Value": {
        "Fn::GetAtt": [
          "ServerGroupAttachment",
          "ScalingActivityId"
        ]
      }
    }
  }
}