ALIYUN::ALB::ServerGroup is used to create a server group.

Syntax

{
  "Type": "ALIYUN::ALB::ServerGroup",
  "Properties": {
    "VpcId": String,
    "ResourceGroupId": String,
    "Scheduler": String,
    "StickySessionConfig": Map,
    "HealthCheckConfig": Map,
    "Protocol": String,
    "ServerGroupType": String,
    "ServerGroupName": String,
    "Tags": List,
    "ServiceName": String
  }
}

Properties

Property Type Required Editable Description Constraint
VpcId String Yes No The ID of the virtual private cloud (VPC). You can add only servers that are deployed in the VPC to the server group.
ResourceGroupId String No Yes The ID of the resource group. None.
Scheduler String No Yes The scheduling algorithm. Valid values:
  • Wrr: Backend servers that have higher weights receive more requests than backend servers that have lower weights. This is the default value.
  • Wlc: Requests are distributed based on the weights and number of connections to backend servers. If multiple backend servers have the same weight, the backend server that has the least connections receives more requests.
  • Sch: Consistent hashing is performed on source IP addresses.
StickySessionConfig Map No Yes The configurations of session persistence. For more information, see StickySessionConfig properties.
HealthCheckConfig Map Yes Yes The configurations of health checks. For more information, see HealthCheckConfig properties.
Protocol String No No The backend protocol. Valid values:
  • HTTP: allows you to associate HTTPS, HTTP, or Quick UDP Internet Connections (QUIC) listeners with the server group. This is the default value.
  • HTTPS: allows you to associate only HTTPS listeners with the server group.
ServerGroupType String No No The type of the server group. Valid values:
  • Instance: servers. You can add Elastic Compute Service (ECS) instances, Edge Node Service (ENS) instances, and Elastic Container Instances (ECIs) to a server group of this type. This is the default value.
  • Ip: IP addresses. You can add servers to a server group of this type by using the IP addresses of the servers.
ServerGroupName String Yes Yes The name of the server group. The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.
Tags List No Yes The tags of the server group. You can specify up to 20 tags for the server group.

For more information, see Tags properties.

ServiceName String No Yes The name of the Kubernetes service that is associated with the server group.
Note This property is applicable only to scenarios where Application Load Balancer (ALB) Ingresses are used.

StickySessionConfig syntax

"StickySessionConfig": {
  "Cookie": String,
  "CookieTimeout": Integer,
  "StickySessionType": String,
  "StickySessionEnabled": Boolean
}

StickySessionConfig properties

Property Type Required Editable Description Constraint
Cookie String No Yes The cookie that you configure for the server. The cookie must be 1 to 200 characters in length, and can contain letters and digits. The cookie cannot contain commas (,), semicolons (;), or spaces. The cookie cannot start with a dollar sign ($).
Note This property is required if you set the StickySessionEnabled property to true and the StickySessionType property to Server.
CookieTimeout Integer No Yes The timeout period of the cookie. Valid values: 1 to 86400.

Default value: 1000.

Unit: seconds.
Note This property is required if you set the StickySessionEnabled property to true and the StickySessionType property to Insert.
StickySessionType String No Yes The method that is used to handle the cookie. Default value: Insert. Valid values:
  • Insert: inserts a cookie. ALB inserts the cookie SERVERID into the first HTTP or HTTPS response packet that is sent to a client. The next request from the client carries the cookie and ALB forwards this request to the backend server that is associated with ALB.
  • Server: rewrites a cookie. When ALB detects a custom cookie that you specify, ALB uses the custom cookie to overwrite the original cookie. The next request from the client carries the custom cookie and ALB forwards this request to the backend server that is associated with ALB.
Note This property is required if you set the StickySessionEnabled property to true.
StickySessionEnabled Boolean No Yes Specifies whether to enable session persistence. Valid values:
  • true: enables session persistence.
  • false: disables session persistence.
Note This property is required if you set the ServerGroupType property to Instance or Ip.

HealthCheckConfig syntax

"HealthCheckConfig": {
  "HealthCheckInterval": Integer,
  "HealthCheckConnectPort": Integer,
  "HealthCheckCodes": List,
  "UnhealthyThreshold": Integer,
  "HealthCheckMethod": String,
  "HealthCheckPath": String,
  "HealthCheckHost": String,
  "HealthyThreshold": Integer,
  "HealthCheckProtocol": String,
  "HealthCheckHttpVersion": String,
  "HealthCheckEnabled": Boolean,
  "HealthCheckTimeout": Integer
}

HealthCheckConfig properties

Property Type Required Editable Description Constraint
HealthCheckInterval Integer No Yes The interval between consecutive health checks. Valid values: 1 to 50.

Default value: 2.

Unit: seconds.
HealthCheckConnectPort Integer No Yes The port that is used for health checks on backend servers. Valid values: 0 to 65535.

Default value: 0. This value indicates that the health check port specified on a backend server is used.

HealthCheckCodes List No Yes The status codes for health checks. Valid values:
  • http_2xx: This is the default value.
  • http_3xx
  • http_4xx
  • http_5xx
Note This property takes effect only if the HealthCheckProtocol property is set to HTTP.
UnhealthyThreshold Integer No Yes The number of consecutive failed health checks that must occur in a healthy backend server before the backend server is declared unhealthy. If this number is reached, the health check status is changed from successful to failed. Valid values: 2 to 10.

Default value: 3.

HealthCheckMethod String No Yes The health check method. Valid values:
  • GET
  • HEAD: This is the default value.
Note This property takes effect only if the HealthCheckProtocol property is set to HTTP.
HealthCheckPath String No Yes The path that is used for health checks. The path must be 1 to 80 characters in length, and can contain letters, digits, and special characters. Special characters include - / . % ? # & = _ ; ~ ! ( ) ∗ [ ] @ $ ^ : ' , +. The path must start with a forward slash (/).
Note This property takes effect only if the HealthCheckProtocol property is set to HTTP.
HealthCheckHost String No Yes The domain name that is used for health checks. The domain name must be 1 to 80 characters in length, and can contain lowercase letters, digits, hyphens (-), and periods (.).

Example: www.example.com.

Note This property takes effect only if the HealthCheckProtocol property is set to HTTP.
HealthyThreshold Integer No Yes The number of consecutive successful health checks that must occur in an unhealthy backend server before the backend server is declared healthy. If this number is reached, the health check status is changed from failed to successful. Valid values: 2 to 10.

Default value: 3.

HealthCheckProtocol String No Yes The protocol that is used for health checks. Valid values:
  • HTTP
  • HTTPS
HealthCheckHttpVersion String No Yes The version of HTTP that is used for health checks. Default value: HTTP1.1. Valid values:
  • HTTP1.0
  • HTTP1.1
Note This property takes effect only if the HealthCheckProtocol property is set to HTTP.
HealthCheckEnabled Boolean Yes Yes Specifies whether to enable health checks. Valid values:
  • true: enables health checks.
  • false: disables health checks.
HealthCheckTimeout Integer No Yes The timeout period of a health check response. If a backend server, such as an Elastic Compute Service (ECS) instance, does not return a health check response within the specified timeout period, the server fails the health check.

Valid values: 1 to 300.

Default value: 5.

Unit: seconds.
Note If the value of the HealthCheckTimeout property is smaller than the value of the HealthCheckInterval property, the timeout period specified by the HealthCheckTimeout property becomes invalid, and the value of the HealthCheckInterval property is used as the timeout period.

Tags syntax

"Tags": [
  {
    "Key": String,
    "Value": String
  }
]  

Tags properties

Property Type Required Editable Description Constraint
Key String Yes No The key of the tag. The tag key must be 1 to 128 characters in length, and cannot contain http:// or https://. The tag key cannot start with aliyun or acs:.
Value String No No The value of the tag. The tag value can be up to 128 characters in length, and cannot contain http:// or https://. The tag value cannot start with aliyun or acs:.

Return values

Fn::GetAtt

ServerGroupId: the ID of the server group.

Example

  • YAML format

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      VpcId:
        AssociationProperty: ALIYUN::ECS::VPC::VPCId
        Type: String
        Label:
           
          en: Existing VPC Instance ID
      StickySessionConfig:
        Type: Json
        Description: |-
          The configuration of session persistence.
          Note This parameter is required if the ServerGroupType parameter is set to Instance or Ip.
        Default:
          Cookie: B490B5EBF6F3CD402E515D22****
          CookieTimeout: 1000
          StickySessionEnabled: true
          StickySessionType: Insert
      HealthCheckConfig:
        Type: Json
        Description: The configuration of health checks.
        Default:
          HealthCheckConnectPort: 80
          HealthCheckEnabled: true
          HealthCheckHost: www.example.com
          HealthCheckCodes:
            - http_2xx
          HealthCheckHttpVersion: HTTP1.0
          HealthCheckInterval: 5
          HealthCheckMethod: HEAD
          HealthCheckPath: /test/index.html
          HealthCheckProtocol: HTTP
          HealthCheckTimeout: 3
          HealthyThreshold: 4
          UnhealthyThreshold: 4
      ServerGroupName:
        Type: String
        Description: |-
          The name of the server group. The name must be 2 to 128 characters in length, and
          can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name
          must start with a letter.
        Default: MyTestServerGroup
    Resources:
      ServerGroup:
        Type: ALIYUN::ALB::ServerGroup
        Properties:
          VpcId:
            Ref: VpcId
          StickySessionConfig:
            Ref: StickySessionConfig
          HealthCheckConfig:
            Ref: HealthCheckConfig
          ServerGroupName:
            Ref: ServerGroupName
    Outputs:
      ServerGroupId:
        Description: The ID of the server group.
        Value:
          Fn::GetAtt:
            - ServerGroup
            - ServerGroupId
                        
  • JSON format

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
        "VpcId": {
          "AssociationProperty": "ALIYUN::ECS::VPC::VPCId",
          "Type": "String",
          "Label": {
             
            "en": "Existing VPC Instance ID"
          }
        },
        "StickySessionConfig": {
          "Type": "Json",
          "Description": "The configuration of session persistence.\nNote This parameter is required if the ServerGroupType parameter is set to Instance or Ip.",
          "Default": {
            "Cookie": "B490B5EBF6F3CD402E515D22****",
            "CookieTimeout": 1000,
            "StickySessionEnabled": true,
            "StickySessionType": "Insert"
          }
        },
        "HealthCheckConfig": {
          "Type": "Json",
          "Description": "The configuration of health checks.",
          "Default": {
            "HealthCheckConnectPort": 80,
            "HealthCheckEnabled": true,
            "HealthCheckHost": "www.example.com",
            "HealthCheckCodes": [
              "http_2xx"
            ],
            "HealthCheckHttpVersion": "HTTP1.0",
            "HealthCheckInterval": 5,
            "HealthCheckMethod": "HEAD",
            "HealthCheckPath": "/test/index.html",
            "HealthCheckProtocol": "HTTP",
            "HealthCheckTimeout": 3,
            "HealthyThreshold": 4,
            "UnhealthyThreshold": 4
          }
        },
        "ServerGroupName": {
          "Type": "String",
          "Description": "The name of the server group. The name must be 2 to 128 characters in length, and\ncan contain letters, digits, periods (.), underscores (_), and hyphens (-). The name\nmust start with a letter.",
          "Default": "MyTestServerGroup"
        }
      },
      "Resources": {
        "ServerGroup": {
          "Type": "ALIYUN::ALB::ServerGroup",
          "Properties": {
            "VpcId": {
              "Ref": "VpcId"
            },
            "StickySessionConfig": {
              "Ref": "StickySessionConfig"
            },
            "HealthCheckConfig": {
              "Ref": "HealthCheckConfig"
            },
            "ServerGroupName": {
              "Ref": "ServerGroupName"
            }
          }
        }
      },
      "Outputs": {
        "ServerGroupId": {
          "Description": "The ID of the server group.",
          "Value": {
            "Fn::GetAtt": [
              "ServerGroup",
              "ServerGroupId"
            ]
          }
        }
      }
    }