ALIYUN::GA::EndpointGroup

更新时间:
复制 MD 格式

ALIYUN::GA::EndpointGroup类型用于创建终端节点组。

语法

{
  "Type": "ALIYUN::GA::EndpointGroup",
  "Properties": {
    "HealthCheckIntervalSeconds": Integer,
    "EndpointGroupRegion": String,
    "TrafficPercentage": Integer,
    "Description": String,
    "HealthCheckPath": String,
    "HealthCheckProtocol": String,
    "ThresholdCount": Integer,
    "HealthCheckPort": Integer,
    "AcceleratorId": String,
    "EndpointConfigurations": List,
    "Name": String,
    "ListenerId": String,
    "HealthCheckEnabled": Boolean,
    "EndpointGroupType": String,
    "HealthCheckHost": String,
    "PortOverrides": List,
    "EndpointIpVersion": String,
    "Tags": List,
    "EndpointProtocolVersion": String,
    "EndpointRequestProtocol": String
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

AcceleratorId

String

全球加速实例ID。

EndpointConfigurations

List

终端节点。

最多设置4个终端节点。

更多信息,请参见EndpointConfigurations属性

EndpointGroupRegion

String

终端节点组所属的地域。

ListenerId

String

监听ID。

Description

String

终端节点组描述信息。

EndpointGroupType

String

终端节点组类型。

取值:

  • default(默认值):默认终端节点组。

  • virtual:虚拟终端节点组。

说明

HTTPHTTPS协议的监听实例才支持创建虚拟终端节点组。

EndpointIpVersion

String

后端 IP 地址协议。

取值:

  • IPv4:(默认值):GA 仅使用 IPv4 地址与终端节点服务通信。

  • IPv6:GA 仅使用 IPv6 地址与终端节点服务通信。

  • ProtocolAffinity:GA 与终端节点服务通信的 IP 协议与客户端请求使用的 IP 协议相同。

EndpointProtocolVersion

String

后端服务协议版本。

取值:

  • HTTP1.1(默认值):HTTP1.1 版本。

  • HTTP2:HTTP2 协议。

说明

仅当 EndpointRequestProtocol(后端服务协议)值为 HTTPS 时,支持配置终端节点后端服务协议版本。

EndpointRequestProtocol

String

后端服务协议。

取值:

  • HTTP(默认值)

  • HTTPS

说明
  • 仅为HTTPHTTPS协议的监听实例创建终端节点组时才支持配置该项。

  • 对于HTTP协议的监听实例,后端服务协议支持且仅支持HTTP。

HealthCheckEnabled

Boolean

是否开启健康检查。

取值:

  • true(默认值):开启健康检查。

  • false:关闭健康检查。

HealthCheckHost

String

健康检查域名。

HealthCheckIntervalSeconds

Integer

健康检查的时间间隔。

单位:秒。

HealthCheckPath

String

健康检查路径。

HealthCheckPort

Integer

健康检查的端口。

HealthCheckProtocol

String

健康检查的协议。

取值:

  • tcp:TCP协议。

  • http:HTTP协议。

  • https:HTTPS协议。

Name

String

终端节点组的名称。

PortOverrides

List

端口映射关系。

更多信息,请参考PortOverrides属性

Tags

List

终端节点组的标签。

更多信息,请参考Tags属性

ThresholdCount

Integer

健康检查判定终端节点为不健康的次数。

TrafficPercentage

Integer

监听有多个终端节点组时的权重。

EndpointConfigurations语法

"EndpointConfigurations": [
  {
    "Type": String,
    "Endpoint": String,
    "Weight": Integer,
    "EnableClientIPPreservation": Boolean,
    "EnableProxyProtocol": Boolean,
    "VpcId": String,
    "VSwitchIds": List,
    "SubAddress": String
  }
]

EndpointConfigurations属性

属性名称

类型

必须

允许更新

描述

约束

Endpoint

String

终端节点的IP或域名。

Type

String

终端节点类型。

取值:

  • Domain:自定义域名。

  • Ip:自定义IP。

Weight

Integer

终端节点的权重。

EnableClientIPPreservation

Boolean

是否使用TOA方式开启保持客户端源IP功能。

取值:

  • true:开启保持客户端源IP功能。

  • false(默认值):不开启保持客户端源IP功能。

EnableProxyProtocol

Boolean

指定是否使用TCP选项地址(TOA)模块获取和保留访问端点的客户端的IP地址。

SubAddress

String

弹性网卡的私网 IP 地址。

说明

当终端节点类型为 ENI 时,可以选择配置该参数,如果不配置默认为 ENI 的主私网 IP 地址。

VpcId

String

专有网络 ID。

VSwitchIds

List

VPC 下的交换机列表。

您最多可以输入 2 个虚拟交换机 ID。

PortOverrides语法

"PortOverrides": [
  {
    "ListenerPort": Integer,
    "EndpointPort": Integer
  }
]

PortOverrides属性

属性名称

类型

必须

允许更新

描述

约束

EndpointPort

Integer

配置端口映射时的终端节点端口。

ListenerPort

Integer

配置端口映射时的监听端口。

说明
  • 对于 TCP 监听:虚拟终端节点组不支持配置端口映射。如果监听下已存在虚拟终端节点组,则默认终端节点组无法配置端口映射。如果默认终端节点组已配置端口映射,则无法添加虚拟终端节点组。

  • 配置端口映射后,后续监听变更时有以下限制:除 HTTP 和 HTTPS 之间的协议切换以外,不支持修改监听协议。

  • 监听端口:您修改的监听端口范围必须包含当前所配置端口映射的全量监听端口。例如,当监听端口范围为 80-82,并配置端口映射至终端节点端口 100-102 时,后续修改监听端口范围时,不支持修改为 80-81。

Tags语法

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

Tags属性

属性名称

类型

必须

允许更新

描述

约束

Key

String

终端节点组的标签键。

一旦输入该值,则不允许为空字符串。

最多支持 64 个字符,不能以aliyunacs:开头,不能包含http://或者https://

最多支持输入 20 个标签键。

Value

String

终端节点组的标签值。

一旦输入该值,可以为空字符串。

最多支持 128 个字符,不能以aliyunacs:开头,不能包含http://或者https://

最多支持输入 20 个标签值。

返回值

Fn::GetAtt

EndpointGroupId:终端节点组ID。

示例

场景 1 :为全球加速监听创建单个终端节点组,将流量转发到SLB实例。

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 为全球加速监听创建单个终端节点组,将流量转发到SLB实例。
  en: Create a single endpoint group for a GA listener to forward traffic to an SLB instance.
Parameters:
  AcceleratorId:
    Type: String
    Label:
      zh-cn: 全球加速实例ID
      en: Accelerator ID
    Description:
      zh-cn: 已有的全球加速实例ID。
      en: The ID of an existing Global Accelerator instance.
  ListenerId:
    Type: String
    Label:
      zh-cn: 监听ID
      en: Listener ID
    Description:
      zh-cn: 全球加速监听器的ID。
      en: The ID of the GA listener.
  EndpointGroupRegion:
    Type: String
    Label:
      zh-cn: 终端节点组地域
      en: Endpoint Group Region
    Description:
      zh-cn: 终端节点组所属的地域ID,即源站所在地域。
      en: The region ID of the endpoint group, where the origin server is located.
    AssociationProperty: ALIYUN::ECS::RegionId
    Default: cn-hangzhou
  SlbInstanceId:
    Type: String
    Label:
      zh-cn: SLB实例ID
      en: SLB Instance ID
    Description:
      zh-cn: 作为终端节点的SLB负载均衡实例ID。
      en: The SLB instance ID to use as an endpoint.
Resources:
  EndpointGroups:
    Type: ALIYUN::GA::EndpointGroups
    Properties:
      AcceleratorId:
        Ref: AcceleratorId
      ListenerId:
        Ref: ListenerId
      EndpointGroupConfigurations:
        - EndpointGroupName: slb-endpoint-group
          EndpointGroupRegion:
            Ref: EndpointGroupRegion
          EndpointGroupType: default
          TrafficPercentage: 100
          EndpointConfigurations:
            - Type: SLB
              Endpoint:
                Ref: SlbInstanceId
              Weight: 100
          HealthCheckEnabled: true
          HealthCheckProtocol: tcp
          HealthCheckIntervalSeconds: 3
          ThresholdCount: 3
Outputs:
  EndpointGroupIds:
    Label:
      zh-cn: 终端节点组ID列表
      en: Endpoint Group IDs
    Description:
      zh-cn: 创建成功的终端节点组ID列表。
      en: The list of created endpoint group IDs.
    Value:
      Fn::GetAtt:
        - EndpointGroups
        - EndpointGroupIds
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "为全球加速监听创建单个终端节点组,将流量转发到SLB实例。",
    "en": "Create a single endpoint group for a GA listener to forward traffic to an SLB instance."
  },
  "Parameters": {
    "AcceleratorId": {
      "Type": "String",
      "Label": {
        "zh-cn": "全球加速实例ID",
        "en": "Accelerator ID"
      },
      "Description": {
        "zh-cn": "已有的全球加速实例ID。",
        "en": "The ID of an existing Global Accelerator instance."
      }
    },
    "ListenerId": {
      "Type": "String",
      "Label": {
        "zh-cn": "监听ID",
        "en": "Listener ID"
      },
      "Description": {
        "zh-cn": "全球加速监听器的ID。",
        "en": "The ID of the GA listener."
      }
    },
    "EndpointGroupRegion": {
      "Type": "String",
      "Label": {
        "zh-cn": "终端节点组地域",
        "en": "Endpoint Group Region"
      },
      "Description": {
        "zh-cn": "终端节点组所属的地域ID,即源站所在地域。",
        "en": "The region ID of the endpoint group, where the origin server is located."
      },
      "AssociationProperty": "ALIYUN::ECS::RegionId",
      "Default": "cn-hangzhou"
    },
    "SlbInstanceId": {
      "Type": "String",
      "Label": {
        "zh-cn": "SLB实例ID",
        "en": "SLB Instance ID"
      },
      "Description": {
        "zh-cn": "作为终端节点的SLB负载均衡实例ID。",
        "en": "The SLB instance ID to use as an endpoint."
      }
    }
  },
  "Resources": {
    "EndpointGroups": {
      "Type": "ALIYUN::GA::EndpointGroups",
      "Properties": {
        "AcceleratorId": {
          "Ref": "AcceleratorId"
        },
        "ListenerId": {
          "Ref": "ListenerId"
        },
        "EndpointGroupConfigurations": [
          {
            "EndpointGroupName": "slb-endpoint-group",
            "EndpointGroupRegion": {
              "Ref": "EndpointGroupRegion"
            },
            "EndpointGroupType": "default",
            "TrafficPercentage": 100,
            "EndpointConfigurations": [
              {
                "Type": "SLB",
                "Endpoint": {
                  "Ref": "SlbInstanceId"
                },
                "Weight": 100
              }
            ],
            "HealthCheckEnabled": true,
            "HealthCheckProtocol": "tcp",
            "HealthCheckIntervalSeconds": 3,
            "ThresholdCount": 3
          }
        ]
      }
    }
  },
  "Outputs": {
    "EndpointGroupIds": {
      "Label": {
        "zh-cn": "终端节点组ID列表",
        "en": "Endpoint Group IDs"
      },
      "Description": {
        "zh-cn": "创建成功的终端节点组ID列表。",
        "en": "The list of created endpoint group IDs."
      },
      "Value": {
        "Fn::GetAtt": [
          "EndpointGroups",
          "EndpointGroupIds"
        ]
      }
    }
  }
}

场景 2 :批量创建多地域终端节点组,配置HTTP健康检查和端口映射。

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 批量创建多地域终端节点组,配置HTTP健康检查和端口映射。
  en: Create multi-region endpoint groups with HTTP health check and port override.
Parameters:
  AcceleratorId:
    Type: String
    Label:
      zh-cn: 全球加速实例ID
      en: Accelerator ID
    Description:
      zh-cn: 已有的全球加速实例ID。
      en: The ID of an existing Global Accelerator instance.
  ListenerId:
    Type: String
    Label:
      zh-cn: 监听ID
      en: Listener ID
    Description:
      zh-cn: 全球加速监听器的ID。
      en: The ID of the GA listener.
  PrimaryAlbId:
    Type: String
    Label:
      zh-cn: 主站ALB实例ID
      en: Primary ALB Instance ID
    Description:
      zh-cn: 杭州地域作为主站的ALB应用型负载均衡实例ID。
      en: The ALB instance ID in Hangzhou as the primary site.
  SecondaryAlbId:
    Type: String
    Label:
      zh-cn: 备站ALB实例ID
      en: Secondary ALB Instance ID
    Description:
      zh-cn: 上海地域作为备站的ALB应用型负载均衡实例ID。
      en: The ALB instance ID in Shanghai as the secondary site.
  PrimaryTrafficPercentage:
    Type: Number
    Label:
      zh-cn: 主站流量比例(%)
      en: Primary Traffic Percentage
    Description:
      zh-cn: 分配到杭州主站的流量比例,剩余流量自动分配到上海备站。
      en: Traffic percentage to the primary Hangzhou site. Remaining goes to Shanghai.
    Default: 80
    MinValue: 0
    MaxValue: 100
Resources:
  EndpointGroups:
    Type: ALIYUN::GA::EndpointGroups
    Properties:
      AcceleratorId:
        Ref: AcceleratorId
      ListenerId:
        Ref: ListenerId
      EndpointGroupConfigurations:
        - EndpointGroupName: primary-hangzhou
          EndpointGroupDescription: 杭州主站终端节点组
          EndpointGroupRegion: cn-hangzhou
          EndpointGroupType: default
          EndpointRequestProtocol: HTTP
          TrafficPercentage:
            Ref: PrimaryTrafficPercentage
          PortOverrides:
            - ListenerPort: 443
              EndpointPort: 80
          EndpointConfigurations:
            - Type: ALB
              Endpoint:
                Ref: PrimaryAlbId
              Weight: 100
          HealthCheckEnabled: true
          HealthCheckProtocol: http
          HealthCheckPort: 80
          HealthCheckPath: /health
          HealthCheckIntervalSeconds: 5
          ThresholdCount: 3
          Tags:
            - Key: Role
              Value: Primary
            - Key: Region
              Value: cn-hangzhou
        - EndpointGroupName: secondary-shanghai
          EndpointGroupDescription: 上海备站终端节点组
          EndpointGroupRegion: cn-shanghai
          EndpointGroupType: default
          EndpointRequestProtocol: HTTP
          TrafficPercentage:
            Fn::Calculate:
              - '{0}-{1}'
              - 0
              - - 100
                - Ref: PrimaryTrafficPercentage
          PortOverrides:
            - ListenerPort: 443
              EndpointPort: 80
          EndpointConfigurations:
            - Type: ALB
              Endpoint:
                Ref: SecondaryAlbId
              Weight: 100
          HealthCheckEnabled: true
          HealthCheckProtocol: http
          HealthCheckPort: 80
          HealthCheckPath: /health
          HealthCheckIntervalSeconds: 5
          ThresholdCount: 3
          Tags:
            - Key: Role
              Value: Secondary
            - Key: Region
              Value: cn-shanghai
Outputs:
  EndpointGroupIds:
    Label:
      zh-cn: 终端节点组ID列表
      en: Endpoint Group IDs
    Description:
      zh-cn: 批量创建的终端节点组ID列表(按配置顺序排列)。
      en: The list of created endpoint group IDs (in configuration order).
    Value:
      Fn::GetAtt:
        - EndpointGroups
        - EndpointGroupIds
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "批量创建多地域终端节点组,配置HTTP健康检查和端口映射。",
    "en": "Create multi-region endpoint groups with HTTP health check and port override."
  },
  "Parameters": {
    "AcceleratorId": {
      "Type": "String",
      "Label": {
        "zh-cn": "全球加速实例ID",
        "en": "Accelerator ID"
      },
      "Description": {
        "zh-cn": "已有的全球加速实例ID。",
        "en": "The ID of an existing Global Accelerator instance."
      }
    },
    "ListenerId": {
      "Type": "String",
      "Label": {
        "zh-cn": "监听ID",
        "en": "Listener ID"
      },
      "Description": {
        "zh-cn": "全球加速监听器的ID。",
        "en": "The ID of the GA listener."
      }
    },
    "PrimaryAlbId": {
      "Type": "String",
      "Label": {
        "zh-cn": "主站ALB实例ID",
        "en": "Primary ALB Instance ID"
      },
      "Description": {
        "zh-cn": "杭州地域作为主站的ALB应用型负载均衡实例ID。",
        "en": "The ALB instance ID in Hangzhou as the primary site."
      }
    },
    "SecondaryAlbId": {
      "Type": "String",
      "Label": {
        "zh-cn": "备站ALB实例ID",
        "en": "Secondary ALB Instance ID"
      },
      "Description": {
        "zh-cn": "上海地域作为备站的ALB应用型负载均衡实例ID。",
        "en": "The ALB instance ID in Shanghai as the secondary site."
      }
    },
    "PrimaryTrafficPercentage": {
      "Type": "Number",
      "Label": {
        "zh-cn": "主站流量比例(%)",
        "en": "Primary Traffic Percentage"
      },
      "Description": {
        "zh-cn": "分配到杭州主站的流量比例,剩余流量自动分配到上海备站。",
        "en": "Traffic percentage to the primary Hangzhou site. Remaining goes to Shanghai."
      },
      "Default": 80,
      "MinValue": 0,
      "MaxValue": 100
    }
  },
  "Resources": {
    "EndpointGroups": {
      "Type": "ALIYUN::GA::EndpointGroups",
      "Properties": {
        "AcceleratorId": {
          "Ref": "AcceleratorId"
        },
        "ListenerId": {
          "Ref": "ListenerId"
        },
        "EndpointGroupConfigurations": [
          {
            "EndpointGroupName": "primary-hangzhou",
            "EndpointGroupDescription": "杭州主站终端节点组",
            "EndpointGroupRegion": "cn-hangzhou",
            "EndpointGroupType": "default",
            "EndpointRequestProtocol": "HTTP",
            "TrafficPercentage": {
              "Ref": "PrimaryTrafficPercentage"
            },
            "PortOverrides": [
              {
                "ListenerPort": 443,
                "EndpointPort": 80
              }
            ],
            "EndpointConfigurations": [
              {
                "Type": "ALB",
                "Endpoint": {
                  "Ref": "PrimaryAlbId"
                },
                "Weight": 100
              }
            ],
            "HealthCheckEnabled": true,
            "HealthCheckProtocol": "http",
            "HealthCheckPort": 80,
            "HealthCheckPath": "/health",
            "HealthCheckIntervalSeconds": 5,
            "ThresholdCount": 3,
            "Tags": [
              {
                "Key": "Role",
                "Value": "Primary"
              },
              {
                "Key": "Region",
                "Value": "cn-hangzhou"
              }
            ]
          },
          {
            "EndpointGroupName": "secondary-shanghai",
            "EndpointGroupDescription": "上海备站终端节点组",
            "EndpointGroupRegion": "cn-shanghai",
            "EndpointGroupType": "default",
            "EndpointRequestProtocol": "HTTP",
            "TrafficPercentage": {
              "Fn::Calculate": [
                "{0}-{1}",
                0,
                [
                  100,
                  {
                    "Ref": "PrimaryTrafficPercentage"
                  }
                ]
              ]
            },
            "PortOverrides": [
              {
                "ListenerPort": 443,
                "EndpointPort": 80
              }
            ],
            "EndpointConfigurations": [
              {
                "Type": "ALB",
                "Endpoint": {
                  "Ref": "SecondaryAlbId"
                },
                "Weight": 100
              }
            ],
            "HealthCheckEnabled": true,
            "HealthCheckProtocol": "http",
            "HealthCheckPort": 80,
            "HealthCheckPath": "/health",
            "HealthCheckIntervalSeconds": 5,
            "ThresholdCount": 3,
            "Tags": [
              {
                "Key": "Role",
                "Value": "Secondary"
              },
              {
                "Key": "Region",
                "Value": "cn-shanghai"
              }
            ]
          }
        ]
      }
    }
  },
  "Outputs": {
    "EndpointGroupIds": {
      "Label": {
        "zh-cn": "终端节点组ID列表",
        "en": "Endpoint Group IDs"
      },
      "Description": {
        "zh-cn": "批量创建的终端节点组ID列表(按配置顺序排列)。",
        "en": "The list of created endpoint group IDs (in configuration order)."
      },
      "Value": {
        "Fn::GetAtt": [
          "EndpointGroups",
          "EndpointGroupIds"
        ]
      }
    }
  }
}

场景 3 :创建多终端节点加权路由的终端节点组,配置客户端源IP保持和HTTPS健康检查。

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 创建多终端节点加权路由的终端节点组,配置客户端源IP保持和HTTPS健康检查。
  en: Create an endpoint group with weighted endpoints, client IP preservation and HTTPS health check.
Parameters:
  AcceleratorId:
    Type: String
    Label:
      zh-cn: 全球加速实例ID
      en: Accelerator ID
    Description:
      zh-cn: 已有的全球加速实例ID。
      en: The ID of an existing Global Accelerator instance.
  ListenerId:
    Type: String
    Label:
      zh-cn: 监听ID
      en: Listener ID
    Description:
      zh-cn: 全球加速监听器的ID。
      en: The ID of the GA listener.
  EndpointGroupRegion:
    Type: String
    Label:
      zh-cn: 终端节点组地域
      en: Endpoint Group Region
    Description:
      zh-cn: 终端节点组所属的地域ID。
      en: The region ID of the endpoint group.
    AssociationProperty: ALIYUN::ECS::RegionId
    Default: cn-hangzhou
  PrimarySlbId:
    Type: String
    Label:
      zh-cn: 主SLB实例ID
      en: Primary SLB Instance ID
    Description:
      zh-cn: 作为主要终端节点的SLB实例ID,承载大部分流量。
      en: The primary SLB instance ID, handling most of the traffic.
  SecondaryEcsIp:
    Type: String
    Label:
      zh-cn: 备用ECS公网IP
      en: Secondary ECS Public IP
    Description:
      zh-cn: 作为备用终端节点的ECS实例公网IP地址。
      en: The public IP of the secondary ECS instance.
  HealthCheckPath:
    Type: String
    Label:
      zh-cn: 健康检查路径
      en: Health Check Path
    Description:
      zh-cn: HTTPS健康检查的URL路径,需返回200状态码表示健康。
      en: HTTPS health check URL path. Must return 200 to indicate healthy.
    Default: /health
  HealthCheckPort:
    Type: Number
    Label:
      zh-cn: 健康检查端口
      en: Health Check Port
    Description:
      zh-cn: 健康检查使用的端口号。
      en: The port number for health checks.
    Default: 443
    MinValue: 1
    MaxValue: 65535
Resources:
  EndpointGroups:
    Type: ALIYUN::GA::EndpointGroups
    Properties:
      AcceleratorId:
        Ref: AcceleratorId
      ListenerId:
        Ref: ListenerId
      EndpointGroupConfigurations:
        - EndpointGroupName: weighted-multi-endpoint
          EndpointGroupDescription: 多终端节点加权路由,SLB为主、ECS为备
          EndpointGroupRegion:
            Ref: EndpointGroupRegion
          EndpointGroupType: default
          EndpointRequestProtocol: HTTPS
          TrafficPercentage: 100
          EnableClientIPPreservationToa: true
          PortOverrides:
            - ListenerPort: 443
              EndpointPort: 443
          EndpointConfigurations:
            - Type: SLB
              Endpoint:
                Ref: PrimarySlbId
              Weight: 200
            - Type: PublicIp
              Endpoint:
                Ref: SecondaryEcsIp
              Weight: 50
          HealthCheckEnabled: true
          HealthCheckProtocol: https
          HealthCheckPort:
            Ref: HealthCheckPort
          HealthCheckPath:
            Ref: HealthCheckPath
          HealthCheckIntervalSeconds: 5
          ThresholdCount: 3
          Tags:
            - Key: Routing
              Value: Weighted
            - Key: IPPreservation
              Value: TOA
Outputs:
  EndpointGroupIds:
    Label:
      zh-cn: 终端节点组ID列表
      en: Endpoint Group IDs
    Description:
      zh-cn: 创建成功的终端节点组ID列表。
      en: The list of created endpoint group IDs.
    Value:
      Fn::GetAtt:
        - EndpointGroups
        - EndpointGroupIds
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "创建多终端节点加权路由的终端节点组,配置客户端源IP保持和HTTPS健康检查。",
    "en": "Create an endpoint group with weighted endpoints, client IP preservation and HTTPS health check."
  },
  "Parameters": {
    "AcceleratorId": {
      "Type": "String",
      "Label": {
        "zh-cn": "全球加速实例ID",
        "en": "Accelerator ID"
      },
      "Description": {
        "zh-cn": "已有的全球加速实例ID。",
        "en": "The ID of an existing Global Accelerator instance."
      }
    },
    "ListenerId": {
      "Type": "String",
      "Label": {
        "zh-cn": "监听ID",
        "en": "Listener ID"
      },
      "Description": {
        "zh-cn": "全球加速监听器的ID。",
        "en": "The ID of the GA listener."
      }
    },
    "EndpointGroupRegion": {
      "Type": "String",
      "Label": {
        "zh-cn": "终端节点组地域",
        "en": "Endpoint Group Region"
      },
      "Description": {
        "zh-cn": "终端节点组所属的地域ID。",
        "en": "The region ID of the endpoint group."
      },
      "AssociationProperty": "ALIYUN::ECS::RegionId",
      "Default": "cn-hangzhou"
    },
    "PrimarySlbId": {
      "Type": "String",
      "Label": {
        "zh-cn": "主SLB实例ID",
        "en": "Primary SLB Instance ID"
      },
      "Description": {
        "zh-cn": "作为主要终端节点的SLB实例ID,承载大部分流量。",
        "en": "The primary SLB instance ID, handling most of the traffic."
      }
    },
    "SecondaryEcsIp": {
      "Type": "String",
      "Label": {
        "zh-cn": "备用ECS公网IP",
        "en": "Secondary ECS Public IP"
      },
      "Description": {
        "zh-cn": "作为备用终端节点的ECS实例公网IP地址。",
        "en": "The public IP of the secondary ECS instance."
      }
    },
    "HealthCheckPath": {
      "Type": "String",
      "Label": {
        "zh-cn": "健康检查路径",
        "en": "Health Check Path"
      },
      "Description": {
        "zh-cn": "HTTPS健康检查的URL路径,需返回200状态码表示健康。",
        "en": "HTTPS health check URL path. Must return 200 to indicate healthy."
      },
      "Default": "/health"
    },
    "HealthCheckPort": {
      "Type": "Number",
      "Label": {
        "zh-cn": "健康检查端口",
        "en": "Health Check Port"
      },
      "Description": {
        "zh-cn": "健康检查使用的端口号。",
        "en": "The port number for health checks."
      },
      "Default": 443,
      "MinValue": 1,
      "MaxValue": 65535
    }
  },
  "Resources": {
    "EndpointGroups": {
      "Type": "ALIYUN::GA::EndpointGroups",
      "Properties": {
        "AcceleratorId": {
          "Ref": "AcceleratorId"
        },
        "ListenerId": {
          "Ref": "ListenerId"
        },
        "EndpointGroupConfigurations": [
          {
            "EndpointGroupName": "weighted-multi-endpoint",
            "EndpointGroupDescription": "多终端节点加权路由,SLB为主、ECS为备",
            "EndpointGroupRegion": {
              "Ref": "EndpointGroupRegion"
            },
            "EndpointGroupType": "default",
            "EndpointRequestProtocol": "HTTPS",
            "TrafficPercentage": 100,
            "EnableClientIPPreservationToa": true,
            "PortOverrides": [
              {
                "ListenerPort": 443,
                "EndpointPort": 443
              }
            ],
            "EndpointConfigurations": [
              {
                "Type": "SLB",
                "Endpoint": {
                  "Ref": "PrimarySlbId"
                },
                "Weight": 200
              },
              {
                "Type": "PublicIp",
                "Endpoint": {
                  "Ref": "SecondaryEcsIp"
                },
                "Weight": 50
              }
            ],
            "HealthCheckEnabled": true,
            "HealthCheckProtocol": "https",
            "HealthCheckPort": {
              "Ref": "HealthCheckPort"
            },
            "HealthCheckPath": {
              "Ref": "HealthCheckPath"
            },
            "HealthCheckIntervalSeconds": 5,
            "ThresholdCount": 3,
            "Tags": [
              {
                "Key": "Routing",
                "Value": "Weighted"
              },
              {
                "Key": "IPPreservation",
                "Value": "TOA"
              }
            ]
          }
        ]
      }
    }
  },
  "Outputs": {
    "EndpointGroupIds": {
      "Label": {
        "zh-cn": "终端节点组ID列表",
        "en": "Endpoint Group IDs"
      },
      "Description": {
        "zh-cn": "创建成功的终端节点组ID列表。",
        "en": "The list of created endpoint group IDs."
      },
      "Value": {
        "Fn::GetAtt": [
          "EndpointGroups",
          "EndpointGroupIds"
        ]
      }
    }
  }
}