All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::ALB::ServerGroup

Last Updated:Feb 10, 2026

Use ALIYUN::ALB::ServerGroup 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,
    "UpstreamKeepaliveEnabled": Boolean,
    "SlowStartConfig": Map,
    "ConnectionDrainConfig": Map,
    "UchConfig": Map,
    "CrossZoneEnabled": Boolean,
    "Ipv6Enabled": Boolean
  }
}

Properties

Property name

Type

Required

Update allowed

Description

Constraints

HealthCheckConfig

Map

Yes

Yes

The health check configuration.

For more information, see HealthCheckConfig properties.

ServerGroupName

String

Yes

Yes

The name of the server group.

The name must be 2 to 128 characters in length. It must start with a letter and can contain digits, periods (.), underscores (_), and hyphens (-).

VpcId

String

No

No

The ID of the virtual private cloud (VPC).

Only servers in this VPC can be added to the server group.

Protocol

String

No

No

The backend protocol.

Valid values:

  • HTTP (default): You can associate HTTPS, HTTP, and QUIC listeners.

  • HTTPS: You can associate HTTPS listeners.

  • gRPC: You can associate HTTPS and QUIC listeners.

Note

If ServerGroupType is set to Fc, only HTTP is supported.

ResourceGroupId

String

No

Yes

The ID of the resource group.

None

Scheduler

String

No

Yes

The scheduling algorithm.

Valid values:

  • Wrr (default): Backend servers with higher weights receive more requests.

  • Wlc: Requests are distributed based on both the weight and the number of connections of each backend server. If servers have the same weight, the server with the fewest connections receives more requests.

  • Sch: Source IP hash.

ServerGroupType

String

No

No

The type of the server group.

Valid values:

  • Instance (default value): the server type.

  • Ip: Specifies the type of IP address.

  • Fc: A Function Compute server group. You can add Function Compute functions as backend servers.

ServiceName

String

No

Yes

The name of the Kubernetes service that corresponds to the server group.

Note

This parameter applies only to Ingress scenarios.

StickySessionConfig

Map

No

Yes

The session persistence configuration.

For more information, see StickySessionConfig properties.

Tags

List

No

Yes

The tags.

You can add up to 20 tags.

For more information, see Tags properties.

UpstreamKeepaliveEnabled

Boolean

No

Yes

Specifies whether to enable keep-alive connections with backend servers.

  • true: Enable

  • false (default): Disable.

SlowStartConfig

Map

No

Yes

The slow start configuration.

If you enable slow start, the number of requests forwarded to a newly added backend server increases linearly over a specified period.

For more information, see SlowStartConfig properties.

Note
  • Basic Edition instances do not support slow start. Only Standard Edition and WAF-enabled instances support this feature.

  • Instance-based and IP-based server groups support slow start. Function Compute server groups do not.

  • You can enable slow start only when the scheduling algorithm is set to weighted round-robin.

ConnectionDrainConfig

Map

No

Yes

The connection draining configuration.

If you enable connection draining, Server Load Balancer allows existing connections to be processed over a specified period after a backend server is removed or fails a health check.

Note

Basic Edition instances do not support connection draining. Only Standard Edition and WAF-enabled instances support this feature.

Instance-based and IP-based server groups support connection draining. Function Compute server groups do not.

UchConfig

Map

No

Yes

The parameters for URL-based consistent hashing.

For more information, see UchConfig properties.

CrossZoneEnabled

Boolean

No

Yes

Specifies whether to enable cross-zone load balancing for the server group.

Valid values:

  • true (default): Enable

  • false: Disable

Note
  • You cannot attach a server group with cross-zone load balancing disabled to a Basic Edition instance. Only Standard Edition and WAF-enabled instances support this configuration.

  • You can disable cross-zone load balancing for instance-based and IP-based server groups. This feature is not supported for Function Compute server groups.

  • If you disable cross-zone load balancing, you cannot enable session persistence.

Ipv6Enabled

Boolean

No

No

Specifies whether to enable IPv6.

None

UchConfig syntax

"UchConfig": {
  "Type": String,
  "Value": String
}

UchConfig properties

Property name

Type

Required

Update allowed

Description

Constraints

Type

String

Yes

No

The type of the parameter.

The value can only be QueryString.

Value

String

Yes

No

The value of the consistent hashing parameter.

None

ConnectionDrainConfig syntax

"ConnectionDrainConfig": {
  "ConnectionDrainTimeout": Integer,
  "ConnectionDrainEnabled": Boolean
}

ConnectionDrainConfig properties

Property Name

Type

Required

Update allowed

Description

Constraints

ConnectionDrainTimeout

Integer

Yes

Yes

The timeout period for connection draining.

Valid values: 0 to 900.

Default value: 300.

ConnectionDrainEnabled

Boolean

Yes

Yes

Specifies whether to enable connection draining.

Valid values:

  • true: Enable.

  • false: Disable.

SlowStartConfig syntax

"SlowStartConfig": {
  "SlowStartDuration": Integer,
  "SlowStartEnabled": Boolean
}

SlowStartConfig properties

Property Name

Type

Required

Update allowed

Description

Constraints

SlowStartDuration

Integer

Yes

Yes

The duration of the slow start.

Valid values: 30 to 900.

Default value: 30.

SlowStartEnabled

Boolean

Yes

Yes

Specifies whether to enable slow start.

Valid values:

  • true: Enable.

  • false: Disable.

StickySessionConfig syntax

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

StickySessionConfig properties

Property Name

Type

Required

Update allowed

Description

Constraints

Cookie

String

No

Yes

The cookie configured on the server.

The cookie must be 1 to 200 characters in length. It cannot start with a dollar sign ($). It can contain letters and digits. It cannot contain commas (,), semicolons (;), or spaces.

Note

This parameter is required if StickySessionEnabled is set to true and StickySessionType is set to Server.

CookieTimeout

Integer

No

Yes

The timeout period of the cookie.

Valid values: 1 to 86,400.

Default value: 1000.

Unit: seconds.

Note

This parameter is required if StickySessionEnabled is set to true and StickySessionType is set to Insert.

StickySessionEnabled

Boolean

No

Yes

Specifies whether to enable session persistence.

Valid values:

  • true: Enable.

  • false: Disable.

Note

This parameter is required if ServerGroupType is set to Instance or Ip.

StickySessionType

String

No

Yes

The method used to process cookies.

Valid values:

  • Insert (default): Inserts a cookie. When a client makes its first request, Server Load Balancer inserts a cookie (SERVERID) into the response. The next time the client sends a request with this cookie, Server Load Balancer forwards the request to the same backend server.

  • Server: Rewrites a cookie. If Server Load Balancer detects a custom cookie, it rewrites the original cookie. The next time the client sends a request with the new cookie, Server Load Balancer forwards the request to the same backend server.

Note

This parameter is required if StickySessionEnabled is set to true.

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 Name

Type

Required

Update allowed

Description

Constraints

HealthCheckEnabled

Boolean

Yes

Yes

Specifies whether to enable health checks.

Valid values:

  • true: Enable.

  • false: Disable.

HealthCheckCodes

List

No

Yes

The list of HTTP status codes for a successful health check.

Valid values:

  • http_2xx (default)

  • http_3xx

  • http_4xx

  • http_5xx

  • If HealthCheckProtocol is set to gRPC, the valid status codes are 0 to 99. Default value: 0. You can specify up to 20 value ranges. Separate multiple ranges with commas (,).

Note

This parameter takes effect when HealthCheckProtocol is set to HTTP, HTTPS, or gRPC.

HealthCheckConnectPort

Integer

No

Yes

The port on the backend server that is used for health checks.

Valid values: 0 to 65,535.

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

HealthCheckHost

String

No

Yes

The domain name for health checks.

The domain name must be 1 to 80 characters in length. It can contain lowercase letters, digits, hyphens (-), and periods (.).

Example: www.example.com.

Note

This parameter takes effect when HealthCheckProtocol is set to HTTP.

HealthCheckHttpVersion

String

No

Yes

The HTTP version for health checks.

Valid values:

  • HTTP1.0

  • HTTP1.1 (default)

Note

This parameter takes effect when HealthCheckProtocol is set to HTTP.

HealthCheckInterval

Integer

No

Yes

The interval between two consecutive health checks.

Valid values: 1 to 50.

Default value: 2.

Unit: seconds.

HealthCheckMethod

String

No

Yes

The health check method.

Valid values:

  • GET

  • HEAD (default)

  • POST: The default method for health checks on gRPC listeners.

Note

This parameter takes effect only when HealthCheckProtocol is set to HTTP, HTTPS, or gRPC.

HealthCheckPath

String

No

Yes

The path for health checks.

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

Note

This parameter takes effect when HealthCheckProtocol is set to HTTP.

HealthCheckProtocol

String

No

Yes

The health check protocol.

Valid values:

  • HTTP: Sends HEAD or GET requests to check the health of the application on the server.

  • HTTPS: Sends HEAD or GET requests to check the health of the application on the server. HTTPS provides data encryption and is more secure than HTTP.

  • TCP: Sends SYN handshake messages to check whether the server port is active.

  • gRPC: Sends POST or GET requests to check the health of the application on the server.

HealthCheckTimeout

Integer

No

Yes

The amount of time to wait for a response from a health check.

If the backend ECS instance does not respond within the specified timeout period, the health check fails.

Valid values: 1 to 300.

Default value: 5.

Unit: seconds.

Note

If the value of HealthCheckTimeout is less than the value of HealthCheckInterval, HealthCheckTimeout is ignored and the value of HealthCheckInterval is used as the timeout period.

HealthyThreshold

Integer

No

Yes

The number of consecutive successful health checks required before a backend server is declared healthy.

Valid values: 2 to 10.

Default value: 3.

UnhealthyThreshold

Integer

No

Yes

The number of consecutive failed health checks required before a backend server is declared unhealthy.

Valid values: 2 to 10.

Default value: 3.

Tags syntax

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

Tags properties

Property Name

Type

Required

Update allowed

Description

Constraints

Key

String

Yes

No

The tag key.

The tag key must be 1 to 128 characters in length. It cannot start with aliyun or acs: and cannot contain http:// or https://.

Value

String

No

No

The tag value.

The tag value can be 0 to 128 characters in length. It cannot start with aliyun or acs: and cannot contain http:// or https://.

Return values

Fn::GetAtt

  • ServerGroupId: The ID of the server group.

  • Arn: The Alibaba Cloud Resource Name (ARN).

Examples

Note

Modify the parameter values based on your requirements.

Scenario 1: Add backend servers to a server group.

Create stack

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  VpcId:
    AssociationProperty: ALIYUN::ECS::VPC::VPCId
    Type: String
    Label:
      zh-cn: Instance ID of the existing VPC
      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                  
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "VpcId": {
      "AssociationProperty": "ALIYUN::ECS::VPC::VPCId",
      "Type": "String",
      "Label": {
        "zh-cn": "Instance ID of the existing VPC",
        "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"
        ]
      }
    }
  }
}

Scenario 2: Create an Application Load Balancer (ALB) instance and add backend servers to a server group.

Create stack

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: Create a dual-zone ALB.
  en: Create a dual-Availability-Zone ALB.
Parameters:
  CommonName:
    Type: String
    Default: elastic-app
  ZoneId1:
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
    AssociationPropertyMetadata:
      ExclusiveTo:
        - ZoneId2
    Label:
      en: Availability Zone
      zh-cn: Zone 1
  ZoneId2:
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
    AssociationPropertyMetadata:
      ExclusiveTo:
        - ZoneId1
    Label:
      en: Availability Zone
      zh-cn: Zone 2
  InstanceType1:
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
    AssociationPropertyMetadata:
      InstanceChargeType: PostPaid
      SystemDiskCategory: cloud_essd
      ZoneId: ${ZoneId}
    Label:
      en: Instance Type
      zh-cn: Instance Type 1
  InstanceType2:
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
    AssociationPropertyMetadata:
      InstanceChargeType: PostPaid
      SystemDiskCategory: cloud_essd
      ZoneId: ${ZoneId}
    Label:
      en: Instance Type
      zh-cn: Instance Type 2
  InstancePassword:
    NoEcho: true
    Type: String
    Description:
      en: >-
        Server login password, Length 8-30, must contain three(Capital letters,
        lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special
        symbol in)
      zh-cn: >-
        The logon password of the server. The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
    Label:
      en: Instance Password
      zh-cn: Instance Password
    ConstraintDescription:
      en: >-
        Length 8-30, must contain three(Capital letters, lowercase letters,
        numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
      zh-cn: 'The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/'
    AssociationProperty: 'ALIYUN::ECS::Instance::Password'
    Default: null
Resources:
  Vpc:
    Type: 'ALIYUN::ECS::VPC'
    Properties:
      CidrBlock: 192.168.0.0/16
      VpcName:
        Fn::Sub: ${CommonName}-vpc
  VSwitch1:
    Type: 'ALIYUN::ECS::VSwitch'
    Properties:
      VpcId:
        Ref: Vpc
      CidrBlock: 192.168.1.0/24
      ZoneId:
        Ref: ZoneId1
      VSwitchName:
        Fn::Sub: ${CommonName}-vsw
  VSwitch2:
    Type: 'ALIYUN::ECS::VSwitch'
    Properties:
      VpcId:
        Ref: Vpc
      CidrBlock: 192.168.2.0/24
      ZoneId:
        Ref: ZoneId2
      VSwitchName:
        Fn::Sub: ${CommonName}-vsw
  SecurityGroup:
    Type: 'ALIYUN::ECS::SecurityGroup'
    Properties:
      VpcId:
        Ref: Vpc
      SecurityGroupName:
        Fn::Sub: ${CommonName}-sg
      SecurityGroupIngress:
        - PortRange: 443/443
          SourceCidrIp: 0.0.0.0/0
          IpProtocol: tcp
        - PortRange: 80/80
          SourceCidrIp: 0.0.0.0/0
          IpProtocol: tcp
  EcsInstance1:
    Type: 'ALIYUN::ECS::InstanceGroup'
    Properties:
      VpcId:
        Ref: Vpc
      ZoneId:
        Ref: ZoneId1
      VSwitchId:
        Ref: VSwitch1
      SecurityGroupId:
        Ref: SecurityGroup
      ImageId: aliyun_3_9_x64_20G_alibase_20231219.vhd
      InstanceName:
        Fn::Sub: ${CommonName}-ecs-1
      InstanceType:
        Ref: InstanceType1
      SystemDiskCategory: cloud_essd
      MaxAmount: 1
      InternetMaxBandwidthOut: 0
      Password:
        Ref: InstancePassword
      UserData:
        Fn::Sub: |-
          #!/bin/bash
          yum -y install nginx-1.20.1
          instanceId=`curl http://100.100.100.200/latest/meta-data/instance-id`
          echo "This is instance1, the instance id is $instanceId" > /usr/share/nginx/html/index.html 
          systemctl start nginx 
          systemctl enable nginx
  EcsInstance2:
    Type: 'ALIYUN::ECS::InstanceGroup'
    Properties:
      VpcId:
        Ref: Vpc
      ZoneId:
        Ref: ZoneId2
      VSwitchId:
        Ref: VSwitch2
      SecurityGroupId:
        Ref: SecurityGroup
      ImageId: aliyun_3_9_x64_20G_alibase_20231219.vhd
      InstanceName:
        Fn::Sub: ${CommonName}-ecs-2
      InstanceType:
        Ref: InstanceType2
      SystemDiskCategory: cloud_essd
      MaxAmount: 1
      InternetMaxBandwidthOut: 0
      Password:
        Ref: InstancePassword
      UserData:
        Fn::Sub: |-
          #!/bin/bash
          yum -y install nginx-1.20.1
          instanceId=`curl http://100.100.100.200/latest/meta-data/instance-id`
          echo "This is instance2, the instance id is $instanceId" > /usr/share/nginx/html/index.html 
          systemctl start nginx 
          systemctl enable nginx
  Alb:
    Type: 'ALIYUN::ALB::LoadBalancer'
    Properties:
      LoadBalancerName:
        Fn::Sub: ${CommonName}-alb
      LoadBalancerEdition: Basic
      VpcId:
        Ref: Vpc
      LoadBalancerBillingConfig:
        PayType: PostPay
      AddressType: Internet
      ZoneMappings:
        - ZoneId:
            Ref: ZoneId1
          VSwitchId:
            Ref: VSwitch1
        - ZoneId:
            Ref: ZoneId2
          VSwitchId:
            Ref: VSwitch2
  AlbServerGroup:
    Type: 'ALIYUN::ALB::ServerGroup'
    Properties:
      VpcId:
        Ref: Vpc
      ServerGroupType: Instance
      ServerGroupName:
        Fn::Sub: ${CommonName}-server-group
      HealthCheckConfig:
        HealthCheckConnectPort: 80
        HealthCheckCodes:
          - http_2xx
          - http_3xx
        HealthCheckProtocol: HTTP
        HealthCheckEnabled: true
        HealthCheckPath: /
      StickySessionConfig:
        StickySessionEnabled: false
  AlbBackendServerAttachment:
    Type: 'ALIYUN::ALB::BackendServerAttachment'
    Properties:
      ServerGroupId:
        Ref: AlbServerGroup
      Servers:
        - ServerType: Ecs
          ServerId:
            Ref: EcsInstance1
          Port: 80
        - ServerType: Ecs
          ServerId:
            Ref: EcsInstance2
          Port: 80
Metadata:
  'ALIYUN::ROS::Interface':
    ParameterGroups:
      - Parameters:
          - ZoneId1
          - ZoneId2
          - InstanceType1
          - InstanceType2
          - InstancePassword
    Hidden:
      - CommonName
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "Create a dual-zone ALB.",
    "en": "Create a dual-Availability-Zone ALB."
  },
  "Parameters": {
    "CommonName": {
      "Type": "String",
      "Default": "elastic-app"
    },
    "ZoneId1": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
      "AssociationPropertyMetadata": {
        "ExclusiveTo": [
          "ZoneId2"
        ]
      },
      "Label": {
        "en": "Availability Zone",
        "zh-cn": "Zone 1"
      }
    },
    "ZoneId2": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
      "AssociationPropertyMetadata": {
        "ExclusiveTo": [
          "ZoneId1"
        ]
      },
      "Label": {
        "en": "Availability Zone",
        "zh-cn": "Zone 2"
      }
    },
    "InstanceType1": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "InstanceChargeType": "PostPaid",
        "SystemDiskCategory": "cloud_essd",
        "ZoneId": "${ZoneId}"
      },
      "Label": {
        "en": "Instance Type",
        "zh-cn": "Instance Type 1"
      }
    },
    "InstanceType2": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "InstanceChargeType": "PostPaid",
        "SystemDiskCategory": "cloud_essd",
        "ZoneId": "${ZoneId}"
      },
      "Label": {
        "en": "Instance Type",
        "zh-cn": "Instance Type 2"
      }
    },
    "InstancePassword": {
      "NoEcho": true,
      "Type": "String",
      "Description": {
        "en": "Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)",
        "zh-cn": "The logon password of the server. The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/"
      },
      "Label": {
        "en": "Instance Password",
        "zh-cn": "Instance Password"
      },
      "ConstraintDescription": {
        "en": "Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)",
        "zh-cn": "The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/"
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::Password",
      "Default": null
    }
  },
  "Resources": {
    "Vpc": {
      "Type": "ALIYUN::ECS::VPC",
      "Properties": {
        "CidrBlock": "192.168.0.0/16",
        "VpcName": {
          "Fn::Sub": "${CommonName}-vpc"
        }
      }
    },
    "VSwitch1": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "CidrBlock": "192.168.1.0/24",
        "ZoneId": {
          "Ref": "ZoneId1"
        },
        "VSwitchName": {
          "Fn::Sub": "${CommonName}-vsw"
        }
      }
    },
    "VSwitch2": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "CidrBlock": "192.168.2.0/24",
        "ZoneId": {
          "Ref": "ZoneId2"
        },
        "VSwitchName": {
          "Fn::Sub": "${CommonName}-vsw"
        }
      }
    },
    "SecurityGroup": {
      "Type": "ALIYUN::ECS::SecurityGroup",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "SecurityGroupName": {
          "Fn::Sub": "${CommonName}-sg"
        },
        "SecurityGroupIngress": [
          {
            "PortRange": "443/443",
            "SourceCidrIp": "0.0.0.0/0",
            "IpProtocol": "tcp"
          },
          {
            "PortRange": "80/80",
            "SourceCidrIp": "0.0.0.0/0",
            "IpProtocol": "tcp"
          }
        ]
      }
    },
    "EcsInstance1": {
      "Type": "ALIYUN::ECS::InstanceGroup",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "ZoneId": {
          "Ref": "ZoneId1"
        },
        "VSwitchId": {
          "Ref": "VSwitch1"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroup"
        },
        "ImageId": "aliyun_3_9_x64_20G_alibase_20231219.vhd",
        "InstanceName": {
          "Fn::Sub": "${CommonName}-ecs-1"
        },
        "InstanceType": {
          "Ref": "InstanceType1"
        },
        "SystemDiskCategory": "cloud_essd",
        "MaxAmount": 1,
        "InternetMaxBandwidthOut": 0,
        "Password": {
          "Ref": "InstancePassword"
        },
        "UserData": {
          "Fn::Sub": "#!/bin/bash\nyum -y install nginx-1.20.1\ninstanceId=`curl http://100.100.100.200/latest/meta-data/instance-id`\necho \"This is instance1, the instance id is $instanceId\" > /usr/share/nginx/html/index.html \nsystemctl start nginx \nsystemctl enable nginx"
        }
      }
    },
    "EcsInstance2": {
      "Type": "ALIYUN::ECS::InstanceGroup",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "ZoneId": {
          "Ref": "ZoneId2"
        },
        "VSwitchId": {
          "Ref": "VSwitch2"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroup"
        },
        "ImageId": "aliyun_3_9_x64_20G_alibase_20231219.vhd",
        "InstanceName": {
          "Fn::Sub": "${CommonName}-ecs-2"
        },
        "InstanceType": {
          "Ref": "InstanceType2"
        },
        "SystemDiskCategory": "cloud_essd",
        "MaxAmount": 1,
        "InternetMaxBandwidthOut": 0,
        "Password": {
          "Ref": "InstancePassword"
        },
        "UserData": {
          "Fn::Sub": "#!/bin/bash\nyum -y install nginx-1.20.1\ninstanceId=`curl http://100.100.100.200/latest/meta-data/instance-id`\necho \"This is instance2, the instance id is $instanceId\" > /usr/share/nginx/html/index.html \nsystemctl start nginx \nsystemctl enable nginx"
        }
      }
    },
    "Alb": {
      "Type": "ALIYUN::ALB::LoadBalancer",
      "Properties": {
        "LoadBalancerName": {
          "Fn::Sub": "${CommonName}-alb"
        },
        "LoadBalancerEdition": "Basic",
        "VpcId": {
          "Ref": "Vpc"
        },
        "LoadBalancerBillingConfig": {
          "PayType": "PostPay"
        },
        "AddressType": "Internet",
        "ZoneMappings": [
          {
            "ZoneId": {
              "Ref": "ZoneId1"
            },
            "VSwitchId": {
              "Ref": "VSwitch1"
            }
          },
          {
            "ZoneId": {
              "Ref": "ZoneId2"
            },
            "VSwitchId": {
              "Ref": "VSwitch2"
            }
          }
        ]
      }
    },
    "AlbServerGroup": {
      "Type": "ALIYUN::ALB::ServerGroup",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "ServerGroupType": "Instance",
        "ServerGroupName": {
          "Fn::Sub": "${CommonName}-server-group"
        },
        "HealthCheckConfig": {
          "HealthCheckConnectPort": 80,
          "HealthCheckCodes": [
            "http_2xx",
            "http_3xx"
          ],
          "HealthCheckProtocol": "HTTP",
          "HealthCheckEnabled": true,
          "HealthCheckPath": "/"
        },
        "StickySessionConfig": {
          "StickySessionEnabled": false
        }
      }
    },
    "AlbBackendServerAttachment": {
      "Type": "ALIYUN::ALB::BackendServerAttachment",
      "Properties": {
        "ServerGroupId": {
          "Ref": "AlbServerGroup"
        },
        "Servers": [
          {
            "ServerType": "Ecs",
            "ServerId": {
              "Ref": "EcsInstance1"
            },
            "Port": 80
          },
          {
            "ServerType": "Ecs",
            "ServerId": {
              "Ref": "EcsInstance2"
            },
            "Port": 80
          }
        ]
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "ZoneId1",
            "ZoneId2",
            "InstanceType1",
            "InstanceType2",
            "InstancePassword"
          ]
        }
      ],
      "Hidden": [
        "CommonName"
      ]
    }
  }
}

Scenario 3: Build a high-availability NGINX website.

Create stack

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: Create a dual-zone, high-availability NGINX website that includes a VPC, ECS instances, an ALB instance, security groups, and automatic deployment configurations.
  en: Establish a dual-Availability Zone high-availability NGINX website, encompassing
    a Virtual Private Cloud (VPC), Elastic Cloud Server (ECS) instances, an Application
    Load Balancer (ALB), Security Groups, and automated deployment configurations.
Parameters:
  CommonName:
    Type: String
    Default: elastic-app
  ZoneId1:
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
    AssociationPropertyMetadata:
      AutoSelectFirst: true
      ExclusiveTo:
        - ZoneId2
    Label:
      en: Availability Zone
      zh-cn: Zone 1
  ZoneId2:
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
    AssociationPropertyMetadata:
      AutoSelectFirst: true
      ExclusiveTo:
        - ZoneId1
    Label:
      en: Availability Zone
      zh-cn: Zone 2
  InstanceType1:
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
    AssociationPropertyMetadata:
      SpotStrategy: SpotAsPriceGo
      InstanceChargeType: PostPaid
      SystemDiskCategory: cloud_essd
      ZoneId: ${ZoneId}
    Label:
      en: Instance Type
      zh-cn: Instance Type 1
    Description:
      zh-cn: This solution creates a spot instance and automatically deploys the NGINX service.
      en: >-
        This solution will create a spot instance and automatically deploy a 
        nginx service.
    Default: null
  InstanceType2:
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
    AssociationPropertyMetadata:
      SpotStrategy: SpotAsPriceGo
      InstanceChargeType: PostPaid
      SystemDiskCategory: cloud_essd
      ZoneId: ${ZoneId}
    Label:
      en: Instance Type
      zh-cn: Instance Type 2
    Description:
      zh-cn: This solution creates a spot instance and automatically deploys the NGINX service.
      en: >-
        This solution will create a spot instance and automatically deploy a 
        nginx service.
    Default: null
  InstancePassword:
    NoEcho: true
    Type: String
    Description:
      en: >-
        Server login password, Length 8-30, must contain three(Capital letters,
        lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special
        symbol in)
      zh-cn: >-
        The logon password of the server. The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
    Label:
      en: Instance Password
      zh-cn: Instance Password
    ConstraintDescription:
      en: >-
        Length 8-30, must contain three(Capital letters, lowercase letters,
        numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
      zh-cn: 'The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/'
    AssociationProperty: 'ALIYUN::ECS::Instance::Password'
    Default: null
Resources:
  Vpc:
    Type: 'ALIYUN::ECS::VPC'
    Properties:
      CidrBlock: 192.168.0.0/16
      VpcName:
        Fn::Sub: ${CommonName}-vpc
  VSwitch1:
    Type: 'ALIYUN::ECS::VSwitch'
    Properties:
      VpcId:
        Ref: Vpc
      CidrBlock: 192.168.1.0/24
      ZoneId:
        Ref: ZoneId1
      VSwitchName:
        Fn::Sub: ${CommonName}-vsw
  VSwitch2:
    Type: 'ALIYUN::ECS::VSwitch'
    Properties:
      VpcId:
        Ref: Vpc
      CidrBlock: 192.168.2.0/24
      ZoneId:
        Ref: ZoneId2
      VSwitchName:
        Fn::Sub: ${CommonName}-vsw
  SecurityGroup:
    Type: 'ALIYUN::ECS::SecurityGroup'
    Properties:
      VpcId:
        Ref: Vpc
      SecurityGroupName:
        Fn::Sub: ${CommonName}-sg
      SecurityGroupIngress:
        - PortRange: 443/443
          SourceCidrIp: 0.0.0.0/0
          IpProtocol: tcp
        - PortRange: 80/80
          SourceCidrIp: 0.0.0.0/0
          IpProtocol: tcp
  EcsInstance1:
    Type: 'ALIYUN::ECS::InstanceGroup'
    Properties:
      VpcId:
        Ref: Vpc
      ZoneId:
        Ref: ZoneId1
      VSwitchId:
        Ref: VSwitch1
      SecurityGroupId:
        Ref: SecurityGroup
      ImageId: aliyun_3_9_x64_20G_alibase_
      InstanceName:
        Fn::Sub: ${CommonName}-ecs-1
      InstanceType:
        Ref: InstanceType1
      SystemDiskCategory: cloud_essd
      MaxAmount: 1
      InternetMaxBandwidthOut: 0
      SpotStrategy: SpotAsPriceGo
      Password:
        Ref: InstancePassword
      UserData:
        Fn::Sub: |-
          #!/bin/bash
          yum -y install nginx-1.20.1
          instanceId=`curl http://100.100.100.200/latest/meta-data/instance-id`
          echo "Welcome to Nginx. Current instance is $instanceId" > /usr/share/nginx/html/index.html 
          systemctl start nginx 
          systemctl enable nginx
  EcsInstance2:
    Type: 'ALIYUN::ECS::InstanceGroup'
    Properties:
      VpcId:
        Ref: Vpc
      ZoneId:
        Ref: ZoneId2
      VSwitchId:
        Ref: VSwitch2
      SecurityGroupId:
        Ref: SecurityGroup
      ImageId: aliyun_3_9_x64_20G_alibase_
      InstanceName:
        Fn::Sub: ${CommonName}-ecs-2
      InstanceType:
        Ref: InstanceType2
      SystemDiskCategory: cloud_essd
      MaxAmount: 1
      InternetMaxBandwidthOut: 0
      SpotStrategy: SpotAsPriceGo
      Password:
        Ref: InstancePassword
      UserData:
        Fn::Sub: |-
          #!/bin/bash
          yum -y install nginx-1.20.1
          instanceId=`curl http://100.100.100.200/latest/meta-data/instance-id`
          echo "Welcome to Nginx. Current instance is $instanceId" > /usr/share/nginx/html/index.html 
          systemctl start nginx 
          systemctl enable nginx
  Alb:
    Type: 'ALIYUN::ALB::LoadBalancer'
    Properties:
      LoadBalancerName:
        Fn::Sub: ${CommonName}-alb
      LoadBalancerEdition: Basic
      VpcId:
        Ref: Vpc
      LoadBalancerBillingConfig:
        PayType: PostPay
      AddressType: Internet
      ZoneMappings:
        - ZoneId:
            Ref: ZoneId1
          VSwitchId:
            Ref: VSwitch1
        - ZoneId:
            Ref: ZoneId2
          VSwitchId:
            Ref: VSwitch2
  AlbServerGroup:
    Type: 'ALIYUN::ALB::ServerGroup'
    Properties:
      VpcId:
        Ref: Vpc
      ServerGroupType: Instance
      ServerGroupName:
        Fn::Sub: ${CommonName}-server-group
      HealthCheckConfig:
        HealthCheckConnectPort: 80
        HealthCheckCodes:
          - http_2xx
          - http_3xx
        HealthCheckProtocol: HTTP
        HealthCheckEnabled: true
        HealthCheckPath: /
      StickySessionConfig:
        StickySessionEnabled: false
  AlbBackendServerAttachment:
    Type: 'ALIYUN::ALB::BackendServerAttachment'
    Properties:
      ServerGroupId:
        Ref: AlbServerGroup
      Servers:
        - ServerType: Ecs
          ServerId:
            Ref: EcsInstance1
          Port: 80
        - ServerType: Ecs
          ServerId:
            Ref: EcsInstance2
          Port: 80
  AlbListener:
    Type: 'ALIYUN::ALB::Listener'
    Properties:
      ListenerPort: 80
      DefaultActions:
        - Type: ForwardGroup
          ForwardGroupConfig:
            ServerGroupTuples:
              - ServerGroupId:
                  Ref: AlbServerGroup
      LoadBalancerId:
        Ref: Alb
      ListenerProtocol: HTTP
Outputs:
  WebUrl:
    Description:
      zh-cn: The web access endpoint.
      en: The Addresses of Web.
    Value:
      'Fn::Sub': 'http://${Alb.DNSName}'
Metadata:
  'ALIYUN::ROS::Interface':
    ParameterGroups:
      - Parameters:
          - ZoneId1
          - InstanceType1
          - ZoneId2
          - InstanceType2
          - InstancePassword
    TemplateTags:
      - acs:example:elastic computing:build a high-availability nginx website
    Hidden:
      - CommonName
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "Create a dual-zone, high-availability NGINX website that includes a VPC, ECS instances, an ALB instance, security groups, and automatic deployment configurations.",
    "en": "Establish a dual-Availability Zone high-availability NGINX website, encompassing a Virtual Private Cloud (VPC), Elastic Cloud Server (ECS) instances, an Application Load Balancer (ALB), Security Groups, and automated deployment configurations."
  },
  "Parameters": {
    "CommonName": {
      "Type": "String",
      "Default": "elastic-app"
    },
    "ZoneId1": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
      "AssociationPropertyMetadata": {
        "AutoSelectFirst": true,
        "ExclusiveTo": [
          "ZoneId2"
        ]
      },
      "Label": {
        "en": "Availability Zone",
        "zh-cn": "Zone 1"
      }
    },
    "ZoneId2": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
      "AssociationPropertyMetadata": {
        "AutoSelectFirst": true,
        "ExclusiveTo": [
          "ZoneId1"
        ]
      },
      "Label": {
        "en": "Availability Zone",
        "zh-cn": "Zone 2"
      }
    },
    "InstanceType1": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "SpotStrategy": "SpotAsPriceGo",
        "InstanceChargeType": "PostPaid",
        "SystemDiskCategory": "cloud_essd",
        "ZoneId": "${ZoneId}"
      },
      "Label": {
        "en": "Instance Type",
        "zh-cn": "Instance Type 1"
      },
      "Description": {
        "zh-cn": "This solution creates a spot instance and automatically deploys the NGINX service.",
        "en": "This solution will create a spot instance and automatically deploy a  nginx service."
      },
      "Default": null
    },
    "InstanceType2": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "SpotStrategy": "SpotAsPriceGo",
        "InstanceChargeType": "PostPaid",
        "SystemDiskCategory": "cloud_essd",
        "ZoneId": "${ZoneId}"
      },
      "Label": {
        "en": "Instance Type",
        "zh-cn": "Instance Type 2"
      },
      "Description": {
        "zh-cn": "This solution creates a spot instance and automatically deploys the NGINX service.",
        "en": "This solution will create a spot instance and automatically deploy a  nginx service."
      },
      "Default": null
    },
    "InstancePassword": {
      "NoEcho": true,
      "Type": "String",
      "Description": {
        "en": "Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)",
        "zh-cn": "The logon password of the server. The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/"
      },
      "Label": {
        "en": "Instance Password",
        "zh-cn": "Instance Password"
      },
      "ConstraintDescription": {
        "en": "Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)",
        "zh-cn": "The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/"
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::Password",
      "Default": null
    }
  },
  "Resources": {
    "Vpc": {
      "Type": "ALIYUN::ECS::VPC",
      "Properties": {
        "CidrBlock": "192.168.0.0/16",
        "VpcName": {
          "Fn::Sub": "${CommonName}-vpc"
        }
      }
    },
    "VSwitch1": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "CidrBlock": "192.168.1.0/24",
        "ZoneId": {
          "Ref": "ZoneId1"
        },
        "VSwitchName": {
          "Fn::Sub": "${CommonName}-vsw"
        }
      }
    },
    "VSwitch2": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "CidrBlock": "192.168.2.0/24",
        "ZoneId": {
          "Ref": "ZoneId2"
        },
        "VSwitchName": {
          "Fn::Sub": "${CommonName}-vsw"
        }
      }
    },
    "SecurityGroup": {
      "Type": "ALIYUN::ECS::SecurityGroup",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "SecurityGroupName": {
          "Fn::Sub": "${CommonName}-sg"
        },
        "SecurityGroupIngress": [
          {
            "PortRange": "443/443",
            "SourceCidrIp": "0.0.0.0/0",
            "IpProtocol": "tcp"
          },
          {
            "PortRange": "80/80",
            "SourceCidrIp": "0.0.0.0/0",
            "IpProtocol": "tcp"
          }
        ]
      }
    },
    "EcsInstance1": {
      "Type": "ALIYUN::ECS::InstanceGroup",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "ZoneId": {
          "Ref": "ZoneId1"
        },
        "VSwitchId": {
          "Ref": "VSwitch1"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroup"
        },
        "ImageId": "aliyun_3_9_x64_20G_alibase_",
        "InstanceName": {
          "Fn::Sub": "${CommonName}-ecs-1"
        },
        "InstanceType": {
          "Ref": "InstanceType1"
        },
        "SystemDiskCategory": "cloud_essd",
        "MaxAmount": 1,
        "InternetMaxBandwidthOut": 0,
        "SpotStrategy": "SpotAsPriceGo",
        "Password": {
          "Ref": "InstancePassword"
        },
        "UserData": {
          "Fn::Sub": "#!/bin/bash\nyum -y install nginx-1.20.1\ninstanceId=`curl http://100.100.100.200/latest/meta-data/instance-id`\necho \"Welcome to Nginx. Current instance is $instanceId\" > /usr/share/nginx/html/index.html \nsystemctl start nginx \nsystemctl enable nginx"
        }
      }
    },
    "EcsInstance2": {
      "Type": "ALIYUN::ECS::InstanceGroup",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "ZoneId": {
          "Ref": "ZoneId2"
        },
        "VSwitchId": {
          "Ref": "VSwitch2"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroup"
        },
        "ImageId": "aliyun_3_9_x64_20G_alibase_",
        "InstanceName": {
          "Fn::Sub": "${CommonName}-ecs-2"
        },
        "InstanceType": {
          "Ref": "InstanceType2"
        },
        "SystemDiskCategory": "cloud_essd",
        "MaxAmount": 1,
        "InternetMaxBandwidthOut": 0,
        "SpotStrategy": "SpotAsPriceGo",
        "Password": {
          "Ref": "InstancePassword"
        },
        "UserData": {
          "Fn::Sub": "#!/bin/bash\nyum -y install nginx-1.20.1\ninstanceId=`curl http://100.100.100.200/latest/meta-data/instance-id`\necho \"Welcome to Nginx. Current instance is $instanceId\" > /usr/share/nginx/html/index.html \nsystemctl start nginx \nsystemctl enable nginx"
        }
      }
    },
    "Alb": {
      "Type": "ALIYUN::ALB::LoadBalancer",
      "Properties": {
        "LoadBalancerName": {
          "Fn::Sub": "${CommonName}-alb"
        },
        "LoadBalancerEdition": "Basic",
        "VpcId": {
          "Ref": "Vpc"
        },
        "LoadBalancerBillingConfig": {
          "PayType": "PostPay"
        },
        "AddressType": "Internet",
        "ZoneMappings": [
          {
            "ZoneId": {
              "Ref": "ZoneId1"
            },
            "VSwitchId": {
              "Ref": "VSwitch1"
            }
          },
          {
            "ZoneId": {
              "Ref": "ZoneId2"
            },
            "VSwitchId": {
              "Ref": "VSwitch2"
            }
          }
        ]
      }
    },
    "AlbServerGroup": {
      "Type": "ALIYUN::ALB::ServerGroup",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "ServerGroupType": "Instance",
        "ServerGroupName": {
          "Fn::Sub": "${CommonName}-server-group"
        },
        "HealthCheckConfig": {
          "HealthCheckConnectPort": 80,
          "HealthCheckCodes": [
            "http_2xx",
            "http_3xx"
          ],
          "HealthCheckProtocol": "HTTP",
          "HealthCheckEnabled": true,
          "HealthCheckPath": "/"
        },
        "StickySessionConfig": {
          "StickySessionEnabled": false
        }
      }
    },
    "AlbBackendServerAttachment": {
      "Type": "ALIYUN::ALB::BackendServerAttachment",
      "Properties": {
        "ServerGroupId": {
          "Ref": "AlbServerGroup"
        },
        "Servers": [
          {
            "ServerType": "Ecs",
            "ServerId": {
              "Ref": "EcsInstance1"
            },
            "Port": 80
          },
          {
            "ServerType": "Ecs",
            "ServerId": {
              "Ref": "EcsInstance2"
            },
            "Port": 80
          }
        ]
      }
    },
    "AlbListener": {
      "Type": "ALIYUN::ALB::Listener",
      "Properties": {
        "ListenerPort": 80,
        "DefaultActions": [
          {
            "Type": "ForwardGroup",
            "ForwardGroupConfig": {
              "ServerGroupTuples": [
                {
                  "ServerGroupId": {
                    "Ref": "AlbServerGroup"
                  }
                }
              ]
            }
          }
        ],
        "LoadBalancerId": {
          "Ref": "Alb"
        },
        "ListenerProtocol": "HTTP"
      }
    }
  },
  "Outputs": {
    "WebUrl": {
      "Description": {
        "zh-cn": "The web access endpoint.",
        "en": "The Addresses of Web."
      },
      "Value": {
        "Fn::Sub": "http://${Alb.DNSName}"
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "ZoneId1",
            "InstanceType1",
            "ZoneId2",
            "InstanceType2",
            "InstancePassword"
          ]
        }
      ],
      "TemplateTags": [
        "acs:example:elastic computing:build a high-availability nginx website"
      ],
      "Hidden": [
        "CommonName"
      ]
    }
  }
}

For more examples, see public templates that contain this resource.