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

PropertyTypeRequiredEditableDescriptionConstraint
VpcIdStringYesNoThe ID of the virtual private cloud (VPC). You can add only servers that are deployed in the VPC to the server group.
ResourceGroupIdStringNoYesThe ID of the resource group. None.
SchedulerStringNoYesThe 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.
StickySessionConfigMapNoYesThe configurations of session persistence. For more information, see StickySessionConfig properties.
HealthCheckConfigMapYesYesThe configurations of health checks. For more information, see HealthCheckConfig properties.
ProtocolStringNoNoThe 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.
ServerGroupTypeStringNoNoThe 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.
ServerGroupNameStringYesYesThe 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.
TagsListNoYesThe tags of the server group. You can specify up to 20 tags for the server group.

For more information, see Tags properties.

ServiceNameStringNoYesThe 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

PropertyTypeRequiredEditableDescriptionConstraint
CookieStringNoYesThe 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.
CookieTimeoutIntegerNoYesThe 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.
StickySessionTypeStringNoYesThe 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.
StickySessionEnabledBooleanNoYesSpecifies 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

PropertyTypeRequiredEditableDescriptionConstraint
HealthCheckIntervalIntegerNoYesThe interval between consecutive health checks. Valid values: 1 to 50.

Default value: 2.

Unit: seconds.
HealthCheckConnectPortIntegerNoYesThe 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.

HealthCheckCodesListNoYesThe 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.
UnhealthyThresholdIntegerNoYesThe 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.

HealthCheckMethodStringNoYesThe 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.
HealthCheckPathStringNoYesThe 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.
HealthCheckHostStringNoYesThe 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.
HealthyThresholdIntegerNoYesThe 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.

HealthCheckProtocolStringNoYesThe protocol that is used for health checks. Valid values:
  • HTTP
  • HTTPS
HealthCheckHttpVersionStringNoYesThe 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.
HealthCheckEnabledBooleanYesYesSpecifies whether to enable health checks. Valid values:
  • true: enables health checks.
  • false: disables health checks.
HealthCheckTimeoutIntegerNoYesThe 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

PropertyTypeRequiredEditableDescriptionConstraint
KeyStringYesNoThe 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:.
ValueStringNoNoThe 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
    Resources:
      ServerGroup:
        Type: ALIYUN::ALB::ServerGroup
        Properties:
          VpcId:
            Ref: VpcId
          StickySessionConfig:
            Cookie: B490B5EBF6F3CD402E515D22****
            CookieTimeout: 1000
            StickySessionEnabled: true
            StickySessionType: Insert
          HealthCheckConfig:
            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: TestServerGroup
    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"
          }
        }
      },
      "Resources": {
        "ServerGroup": {
          "Type": "ALIYUN::ALB::ServerGroup",
          "Properties": {
            "VpcId": {
              "Ref": "VpcId"
            },
            "StickySessionConfig": {
              "Cookie": "B490B5EBF6F3CD402E515D22****",
              "CookieTimeout": 1000,
              "StickySessionEnabled": true,
              "StickySessionType": "Insert"
            },
            "HealthCheckConfig": {
              "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": "TestServerGroup"
          }
        }
      },
      "Outputs": {
        "ServerGroupId": {
          "Description": "The ID of the server group.",
          "Value": {
            "Fn::GetAtt": [
              "ServerGroup",
              "ServerGroupId"
            ]
          }
        }
      }
    }