All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::NLB::ServerGroup

Last Updated:Jul 03, 2024

ALIYUN::NLB::ServerGroup is used to create a server group for a Network Load Balancer (NLB) instance.

Syntax

{
  "Type": "ALIYUN::NLB::ServerGroup",
  "Properties": {
    "ResourceGroupId": String,
    "Scheduler": String,
    "AddressIPVersion": String,
    "Servers": List,
    "PreserveClientIpEnabled": Boolean,
    "ServerGroupType": String,
    "PersistenceEnabled": Boolean,
    "ConnectionDrainEnabled": Boolean,
    "ConnectionDrainTimeout": Integer,
    "PersistenceTimeout": Integer,
    "VpcId": String,
    "HealthCheckConfig": Map,
    "Protocol": String,
    "ServerGroupName": String,
    "Tags": List,
    "AnyPortEnabled": Boolean
  }
}

Properties

Property

Type

Required

Editable

Description

Constraint

ResourceGroupId

String

No

No

The ID of the resource group.

None.

Scheduler

String

No

No

The scheduling algorithm.

Valid values:

  • Wrr (default): weighted round-robin (WRR). Backend servers that have higher weights receive more requests than backend servers that have lower weights.

  • rr: round-robin (RR). Requests are forwarded to backend servers in sequence.

  • sch: source IP address hashing. Requests from the same source IP address are forwarded to the same backend server.

  • tch: consistent hashing that is based on four factors. Requests that contain the same information based on the following factors are forwarded to the same backend server: source IP address, destination IP address, source port, and destination port.

  • qch: Quick UDP Internet Connection (QUIC) ID hashing. Requests that contain the same QUIC ID are forwarded to the same backend server.

AddressIPVersion

String

No

No

The IP version.

Valid values:

  • ipv4 (default): IPv4

  • DualStack: dual stack

Servers

List

No

No

The servers.

For more information, see Servers properties.

PreserveClientIpEnabled

Boolean

No

No

Specifies whether to enable client IP preservation.

Valid values:

  • true

  • false (default)

ServerGroupType

String

No

No

The type of the server group.

Valid values:

  • Instance (default): allows you to add Elastic Compute Service (ECS) instances, Edge Node Service (ENS) instances, and elastic container instances as backend servers.

  • Ip: allows you to add servers by specifying IP addresses.

PersistenceEnabled

Boolean

No

No

Specifies whether to enable session persistence.

Valid values:

  • true

  • false

ConnectionDrainEnabled

Boolean

No

No

Specifies whether to enable connection draining.

Valid values:

  • true

  • false (default)

ConnectionDrainTimeout

Integer

No

No

The timeout period of connection draining.

Unit: seconds.

Valid values: 10 to 900.

PersistenceTimeout

Integer

No

No

The timeout period of session persistence.

Unit: seconds.

Valid values: 0 to 3600.

VpcId

String

Yes

No

The ID of the virtual private cloud (VPC) to which the server group belongs.

Note

When you set ServerGroupType to Instance, you can add servers to the server group only if the servers and the server group are in the same VPC.

HealthCheckConfig

Map

No

No

The configurations of the health check feature.

For more information, see HealthCheckConfig properties.

Protocol

String

No

No

The backend protocol.

Valid values:

  • TCP (default)

  • UDP

  • TCPSSL

ServerGroupName

String

Yes

No

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 (-). It must start with a letter.

AnyPortEnabled

Boolean

No

No

Specifies whether to enable multi-port forwarding.

Valid values:

  • true

  • false

Tags

List

No

Yes

The tags.

For more information, see Tags properties.

Servers syntax

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

Servers properties

Property

Type

Required

Editable

Description

Constraint

ServerType

String

Yes

No

The type of the backend server.

Valid values:

  • Ecs (default): ECS instance

  • Eni: elastic network interface (ENI)

  • Eci: elastic container instance

  • Ip: IP address

Description

String

No

No

The description of the backend server.

None.

ServerId

String

Yes

No

The ID of the instance that you want to use as the backend server.

Valid values:

  • ID of the ECS instance

  • ID of the ENI

  • ID of the elastic container instance

Note

You must specify ServerType when ServerId is set to the ID of the ENI or elastic container instance.

ServerIp

String

No

No

The IP address of the ECS instance, ENI, or elastic container instance.

None.

Port

Integer

No

No

The backend port that you want to use to receive requests.

None.

Weight

Integer

No

No

The weight of the backend server.

Valid values: 0 to 100.

Default value: 100.

HealthCheckConfig syntax

"HealthCheckConfig": {
  "HealthCheckInterval": Integer,
  "HealthCheckUrl": String,
  "HealthCheckConnectPort": Integer,
  "UnhealthyThreshold": Integer,
  "HttpCheckMethod": String,
  "HealthyThreshold": Integer,
  "HealthCheckConnectTimeout": Integer,
  "HealthCheckDomain": String,
  "HealthCheckEnabled": Boolean,
  "HealthCheckHttpCode": List,
  "HealthCheckType": String
}

HealthCheckConfig properties

Property

Type

Required

Editable

Description

Constraint

HealthCheckInterval

Integer

No

No

The interval between two consecutive health checks.

Unit: seconds.

Valid values: 5 to 50.

Default value: 10.

HealthCheckUrl

String

No

No

The path based on which the system performs health checks.

The path must be 1 to 80 characters in length, and can contain only letters, digits, the - / . % ? # & = special characters, and the _ ; ~ ! ( ) * [ ] @ $ ^ : ' , + extended characters. It must start with a forward slash (/).

Note

This property takes effect when HealthCheckType is set to Http.

HealthCheckConnectPort

Integer

No

No

The backend port that you want to use for health checks.

Valid values: 0 to 65535.

Default value: 0. A value of 0 indicates that the port of a backend server is used for health checks.

UnhealthyThreshold

Integer

No

No

The number of times that a healthy backend server must consecutively fail health checks before it is declared unhealthy.

Valid values: 2 to 10.

Default value: 2.

HttpCheckMethod

String

Yes

No

The method that you want to use for health checks.

Valid values:

  • GET (default)

  • HEAD

Note

This property takes effect when HealthCheckType is set to Http.

HealthyThreshold

Integer

No

No

The number of times that an unhealthy backend server must consecutively pass health checks before it is declared healthy.

Valid values: 2 to 10.

Default value: 2.

HealthCheckConnectTimeout

Integer

No

No

The maximum timeout period of a health check response.

Unit: seconds.

Valid values: 1 to 300.

Default value: 5.

HealthCheckDomain

String

No

No

The domain name that you want to use for health checks.

Valid values:

  • $SERVER_IP: the private IP address of a backend server.

  • domain: the domain name that you specify. The domain name must be 1 to 80 characters in length, and can contain only lowercase letters, digits, hyphens (-), and periods (.).

Note

This property takes effect when HealthCheckType is set to Http.

HealthCheckEnabled

Boolean

No

No

Specifies whether to enable the health check feature.

Valid values:

  • true (default)

  • false

HealthCheckHttpCode

List

No

No

The HTTP status codes that the system returns for health checks.

Separate multiple HTTP status codes with commas (,).

Valid values:

  • http_2xx (default)

  • http_3xx

  • http_4xx

  • http_5xx

Note

This property takes effect when HealthCheckType is set to Http.

HealthCheckType

String

No

No

The protocol that you want to use for health checks.

Valid values:

  • Tcp (default)

  • Http

Tags syntax

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

Tags properties

Property

Type

Required

Editable

Description

Constraint

Key

String

Yes

No

The tag key.

None.

Value

String

No

No

The tag value.

None.

Return values

Fn::GetAtt

ServerGroupId: the ID of the server group.

Examples

The following section provides examples on how to create a server group that is associated with a specified IP address.

YAML format

ROSTemplateFormatVersion: '2015-09-01'
Description: ''
Parameters:
  VpcId:
    Type: String
    AssociationProperty: ALIYUN::ECS::VPC::VPCId
Resources:
  NlbServerGroup:
    Type: ALIYUN::NLB::ServerGroup
    Properties:
      Servers:
        - ServerId: 10.1.1.102
          ServerIp: 10.1.1.102
          Port: 80
          Weight: 100
          ServerType: Ip
      ServerGroupType: Ip
      ServerGroupName: Test
      VpcId:
        Ref: VpcId
      HealthCheckConfig:
        HttpCheckMethod: Get
        HealthCheckEnabled: true
        HealthCheckConnectTimeout: Null
      Protocol: TCP
Outputs: {}

JSON format

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": "",
  "Parameters": {
    "VpcId": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::VPC::VPCId"
    }
  },
  "Resources": {
    "NlbServerGroup": {
      "Type": "ALIYUN::NLB::ServerGroup",
      "Properties": {
        "Servers": [
          {
            "ServerId": "10.1.1.102",
            "ServerIp": "10.1.1.102",
            "Port": 80,
            "Weight": 100,
            "ServerType": "Ip"
          }
        ],
        "ServerGroupType": "Ip",
        "ServerGroupName": "Test",
        "VpcId": {
          "Ref": "VpcId"
        },
        "HealthCheckConfig": {
          "HttpCheckMethod": "Get",
          "HealthCheckEnabled": true,
          "HealthCheckConnectTimeout": null
        },
        "Protocol": "TCP"
      }
    }
  },
  "Outputs": {
  }
}