全部產品
Search
文件中心

Resource Orchestration Service:ALIYUN::SLB::LoadBalancer

更新時間:Feb 06, 2026

ALIYUN::SLB::LoadBalancer類型用於建立Server Load Balancer執行個體。

文法

{
  "Type": "ALIYUN::SLB::LoadBalancer",
  "Properties": {
    "DeletionProtection": Boolean,
    "AddressType": String,
    "Tags": List,
    "InternetChargeType": String,
    "Bandwidth": Integer,
    "SlaveZoneId": String,
    "ResourceGroupId": String,
    "VpcId": String,
    "LoadBalancerName": String,
    "VSwitchId": String,
    "LoadBalancerSpec": String,
    "MasterZoneId": String,
    "ModificationProtectionReason": String,
    "ModificationProtectionStatus": String,
    "AddressIPVersion": String,
    "InstanceChargeType": String
  }
}

屬性

屬性名稱

類型

必須

允許更新

描述

約束

ResourceGroupId

String

資源群組ID。

DeletionProtection

Boolean

是否開啟刪除保護。

取值:

  • true:開啟刪除保護。

  • false(預設值):不開啟刪除保護。

VpcId

String

專用網路ID。

SlaveZoneId

String

Server Load Balancer執行個體的可用性區域ID。

Bandwidth

Integer

按固定頻寬計費方式的公網類型執行個體的頻寬峰值。

取值範圍:1~10000。

單位:Mbps。

預設值:1。

專用網路執行個體系統會統一按流量計費設定該參數。

  • 針對按固定頻寬計費方式的公網類型執行個體,需要將當前設定值通過Listener中的Bandwidth參數進行分配後才會生效。

  • 針對按使用流量計費方式的公網類型執行個體的頻寬峰值,請直接通過Listener上Bandwidth參數進行設定,此時該參數會被忽略。

AddressType

String

Server Load Balancer執行個體的地址類型。

取值:

  • internet(預設值):負載平衡具有公網IP地址,DNS網域名稱被解析到公網IP,因此可以在公網環境訪問。

  • intranet:負載平衡只有私網IP地址,DNS網域名稱被解析到私網IP,因此只能被負載平衡所在VPC的內網環境訪問。

VSwitchId

String

交換器ID。

LoadBalancerName

String

Server Load Balancer執行個體的名稱。

長度為1~80個字元。可包含英文字母、數字、短劃線(-)、正斜線(/)、半形句號(.)和底線(_)。

不指定該參數時,預設由系統分配一個執行個體名稱。

InternetChargeType

String

公網類型執行個體付費方式。

取值:

  • paybybandwidth:按頻寬計費。

  • paybytraffic(預設值):按流量計費。

MasterZoneId

String

執行個體的主可用性區域ID。

Tags

List

Server Load Balancer執行個體的標籤。

最多支援5個標籤。

更多資訊,請參見Tags屬性

LoadBalancerSpec

String

Server Load Balancer執行個體的規格。

取值:

  • slb.s1.small(預設值)

  • slb.s2.small

  • slb.s2.medium

  • slb.s3.small

  • slb.s3.medium

  • slb.s3.large

  • slb.s3.xlarge

  • slb.s3.xxlarge

每個地區支援的規格不同。關於每種規格的說明,參見效能保障型執行個體

ModificationProtectionStatus

String

修改保護狀態。

取值:

  • NonProtection(預設值):不開啟。

  • ConsoleProtection:允許通過控制台修改。

ModificationProtectionReason

String

修改保護狀態的原因。

長度為1~80個字元,以英文字母或漢字開頭。可包含英文字母、漢字、數字、半形句號(.)和短劃線(-)。

AddressIPVersion

String

IP版本。

取值:

  • ipv4

  • ipv6

    說明

    取值為ipv6時,請注意支援地區和規範。

InstanceChargeType

String

執行個體計費方式。

取值:

  • PayBySpec(預設值):按規格計費。

  • PayByCLCU:隨用隨付。

Tags文法

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

Tags屬性

屬性名稱

類型

必須

允許更新

描述

約束

Key

String

標籤鍵。

長度為1~64個字元,不能以aliyunacs:開頭,不能包含http://https://

Value

String

標籤值。

長度為0~128個字元,不能以aliyunacs:開頭,不能包含http://https://

傳回值

Fn::GetAtt

  • LoadBalancerId:Server Load Balancer執行個體的ID。

  • NetworkType:Server Load Balancer執行個體的網路類型。

  • AddressType:Server Load Balancer執行個體的地址類型。

  • IpAddress:Server Load Balancer執行個體的IP地址。

  • OrderId:訂單ID。

  • Bandwidth:頻寬峰值。

  • AddressIPVersion:Server Load Balancer執行個體的IP版本。

  • SlaveZoneId:Server Load Balancer執行個體的備可用性區域ID。

  • MasterZoneId:Server Load Balancer執行個體的主可用性區域ID。

  • LoadBalancerName:Server Load Balancer執行個體的名稱。

  • ResourceGroupId:資源群組ID。

  • LoadBalancerSpec:Server Load Balancer執行個體的規格。

  • VpcId:Server Load Balancer執行個體的所屬專用網路的ID。

  • VSwitchId:Server Load Balancer執行個體的所屬交換器的ID。

  • PayType:執行個體計費方式。

樣本

情境 1 :建立Server Load Balancer執行個體

快速建立

ROSTemplateFormatVersion: '2015-09-01'
Description: Test SLB LoadBalancer
Parameters:
  MasterZoneId:
    Type: String
    AssociationProperty: ALIYUN::ECS::Instance:ZoneId
Resources:
  LoadBalance:
    Type: ALIYUN::SLB::LoadBalancer
    Properties:
      AddressType: internet
      LoadBalancerSpec: slb.s1.small
      MasterZoneId:
        Ref: MasterZoneId
      LoadBalancerName: mytest
Outputs: {}
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": "Test SLB LoadBalancer",
  "Parameters": {
    "MasterZoneId": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::Instance:ZoneId"
    }
  },
  "Resources": {
    "LoadBalance": {
      "Type": "ALIYUN::SLB::LoadBalancer",
      "Properties": {
        "AddressType": "internet",
        "LoadBalancerSpec": "slb.s1.small",
        "MasterZoneId": {
          "Ref": "MasterZoneId"
        },
        "LoadBalancerName": "mytest"
      }
    }
  },
  "Outputs": {
  }
}

情境 2 :建立ECS執行個體組,並綁定至SLB執行個體

快速建立

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 建立ECS執行個體組,配置靈活,自動綁定至三個SLB執行個體,實現負載平衡。
  en: Create an ECS instance group with flexible configuration and automatically bind to three SLB instances to achieve load balancing.
Parameters:
  ZoneId:
    Type: String
    Default: null
    Required: true
    Label:
      en: Availability Zone
      zh-cn: 可用性區域
    AssociationProperty: ALIYUN::ECS::Instance::ZoneId
    AssociationPropertyMetadata:
      AutoSelectFirst: true
  VpcId:
    Type: String
    AssociationProperty: ALIYUN::ECS::VPC::VPCId
  VSwitchId:
    Type: String
    AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
    AssociationPropertyMetadata:
      ZoneId: ${ZoneId}
      VpcId: ${VpcId}
  SecurityGroupId:
    Type: String
    Label:
      en: Business Security Group ID
      zh-cn: 業務安全性群組ID
    AssociationProperty: ALIYUN::ECS::SecurityGroup::SecurityGroupId
    AssociationPropertyMetadata:
      VpcId: ${VpcId}
  InstanceType:
    Type: String
    Label: ECS Instance Type
    AssociationProperty: ALIYUN::ECS::Instance::InstanceType
    AssociationPropertyMetadata:
      ZoneId: ZoneId
  Password:
    Type: String
    Label: ECS Instance Password
    AssociationProperty: ALIYUN::ECS::Instance::Password
  SlbInstanceId:
    AssociationProperty: ALIYUN::SLB::LoadBalancer::LoadBalancerId
    Type: String
Resources:
  InstanceGroup:
    Type: ALIYUN::ECS::InstanceGroup
    Properties:
      VpcId:
        Ref: VpcId
      VSwitchId:
        Ref: VSwitchId
      SecurityGroupId:
        Ref: SecurityGroupId
      ImageId: centos_7
      AllocatePublicIP: 'false'
      MaxAmount: 2
      Password:
        Ref: Password
      InstanceType:
        Ref: InstanceType
      SystemDiskCategory: cloud_essd
      UserData:
        Fn::Join:
        - ''
        - - '#!/bin/sh

            '
          - 'ip_addr=`ifconfig eth0 | awk ''/inet /{print $2}''`

            '
          - 'host_name=`hostname`

            '
          - 'echo "$ip_addr $host_name" >> /etc/hosts

            '
  AttachmentECSToSLB:
    Type: ALIYUN::SLB::BackendServerAttachment
    Properties:
      LoadBalancerId:
        Ref: SlbInstanceId
      BackendServerList:
        Fn::GetAtt:
        - InstanceGroup
        - InstanceIds
      BackendServerWeightList:
      - '100'
Outputs:
  InstanceIds:
    Description: The instance id list of created ecs instance.
    Value:
      Fn::GetAtt:
      - InstanceGroup
      - InstanceIds
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "建立ECS執行個體組,配置靈活,自動綁定至三個SLB執行個體,實現負載平衡。",
    "en": "Create an ECS instance group with flexible configuration and automatically bind to three SLB instances to achieve load balancing."
  },
  "Parameters": {
    "ZoneId": {
      "Type": "String",
      "Default": null,
      "Required": true,
      "Label": {
        "en": "Availability Zone",
        "zh-cn": "可用性區域"
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
      "AssociationPropertyMetadata": {
        "AutoSelectFirst": true
      }
    },
    "VpcId": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::VPC::VPCId"
    },
    "VSwitchId": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId",
      "AssociationPropertyMetadata": {
        "ZoneId": "${ZoneId}",
        "VpcId": "${VpcId}"
      }
    },
    "SecurityGroupId": {
      "Type": "String",
      "Label": {
        "en": "Business Security Group ID",
        "zh-cn": "業務安全性群組ID"
      },
      "AssociationProperty": "ALIYUN::ECS::SecurityGroup::SecurityGroupId",
      "AssociationPropertyMetadata": {
        "VpcId": "${VpcId}"
      }
    },
    "InstanceType": {
      "Type": "String",
      "Label": "ECS Instance Type",
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "ZoneId": "ZoneId"
      }
    },
    "Password": {
      "Type": "String",
      "Label": "ECS Instance Password",
      "AssociationProperty": "ALIYUN::ECS::Instance::Password"
    },
    "SlbInstanceId": {
      "AssociationProperty": "ALIYUN::SLB::LoadBalancer::LoadBalancerId",
      "Type": "String"
    }
  },
  "Resources": {
    "InstanceGroup": {
      "Type": "ALIYUN::ECS::InstanceGroup",
      "Properties": {
        "VpcId": {
          "Ref": "VpcId"
        },
        "VSwitchId": {
          "Ref": "VSwitchId"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroupId"
        },
        "ImageId": "centos_7",
        "AllocatePublicIP": "false",
        "MaxAmount": 2,
        "Password": {
          "Ref": "Password"
        },
        "InstanceType": {
          "Ref": "InstanceType"
        },
        "SystemDiskCategory": "cloud_essd",
        "UserData": {
          "Fn::Join": [
            "",
            [
              "#!/bin/sh\n",
              "ip_addr=`ifconfig eth0 | awk '/inet /{print $2}'`\n",
              "host_name=`hostname`\n",
              "echo \"$ip_addr $host_name\" >> /etc/hosts\n"
            ]
          ]
        }
      }
    },
    "AttachmentECSToSLB": {
      "Type": "ALIYUN::SLB::BackendServerAttachment",
      "Properties": {
        "LoadBalancerId": {
          "Ref": "SlbInstanceId"
        },
        "BackendServerList": {
          "Fn::GetAtt": [
            "InstanceGroup",
            "InstanceIds"
          ]
        },
        "BackendServerWeightList": [
          "100"
        ]
      }
    }
  },
  "Outputs": {
    "InstanceIds": {
      "Description": "The instance id list of created ecs instance.",
      "Value": {
        "Fn::GetAtt": [
          "InstanceGroup",
          "InstanceIds"
        ]
      }
    }
  }
}

情境 3 :建立電商網站防護方案

快速建立

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 建立電商網站防護方案,含VPC、ECS、SLB、RDS資源,確保穩定性與優惠真實性,跨可用性區域部署。
  en: Develop an e-commerce website protection plan, encompassing Virtual Private
    Cloud (VPC), Elastic Compute Service (ECS), Server Load Balancer (SLB), and Relational
    Database Service (RDS) resources. Implement measures to prevent scalpers from
    exploiting promotions, ensuring service stability and the authenticity of discounts.
    Deploy across multiple availability zones for redundancy and high availability.
Parameters:
  VpcCidrBlock:
    Type: String
    Label:
      en: VPC CIDR Block
      zh-cn: 專用網路網段
    Description:
      en: 'The IP address range of the VPC in the CIDR Block form; <br>You can use
        the following IP address ranges: <br><font color=''green''>[10.0.0.0/8]</font><br><font
        color=''green''>[172.16.0.0/12]</font><br><font color=''green''>[192.168.0.0/16]</font>'
      zh-cn: 專用網路IP位址區段範圍,<br>您可以使用以下的IP位址區段:<br><font color='green'>[10.0.0.0/8]</font><br><font
        color='green'>[172.16.0.0/12]</font><br><font color='green'>[192.168.0.0/16]</font>
    Default: 192.168.0.0/16
    AllowedValues:
    - 10.0.0.0/8
    - 172.16.0.0/12
    - 192.168.0.0/16
  VSwitchZoneId:
    Type: String
    Label:
      en: Master Zone
      zh-cn: 主可用性區域
    Description:
      en: 'Availability Zone ID;<br><b>note: <font color=''blue''>before selecting
        the Available Zone, verify that the Available Zone supports the specification
        for creating SLB、RDS、ECS resources.</font></b>'
      zh-cn: 可用性區域ID;<br><b>註: <font color='blue'>選擇可用性區域前請確認該可用性區域是否支援建立SLB、RDS、ECS資源的規格。</font></b>
    AssociationProperty: ALIYUN::ECS::Instance:ZoneId
  VswCidrBlock:
    Type: String
    Label:
      en: Master Zone CIDR Block
      zh-cn: 主可用性區域網段
    Description:
      en: Must be a subnet segment that belongs to a proprietary network and is not
        occupied by another VSwitch.
      zh-cn: 必須是所屬專用網路的子網段,並且沒有被其他交換器佔用。
    Default: 192.168.1.0/24
  VSwitchZoneId2:
    Type: String
    Label:
      en: Slave Zone
      zh-cn: 備可用性區域
    Description:
      en: 'Availability Zone ID,<br><b>note: <font color=''blue''>before selecting
        the Availability Zone, verify that the available zone supports the specification
        for creating SLB resources,not the same as Master Zone.</font></b>'
      zh-cn: 可用性區域ID,<br><b>註: <font color='blue'>選擇可用性區域前請確認該可用性區域是否支援建立SLB資源的規格,並不同於主可用性區域。</font></b>
    AssociationProperty: ALIYUN::ECS::Instance:ZoneId
  VswCidrBlock2:
    Type: String
    Label:
      en: Slave Zone CIDR Block
      zh-cn: 備可用性區域網段
    Description:
      en: Must be a subnet segment that belongs to a proprietary network and is not
        occupied by another VSwitch.
      zh-cn: 必須是所屬專用網路的子網段,並且沒有被其他交換器佔用。
    Default: 192.168.2.0/24
  EcsInstanceType:
    Type: String
    Label:
      en: Instance Type
      zh-cn: 執行個體規格
    Description:
      en: 'Fill in the specifications that can be used under the VSwitch availability
        zone;</b></font><br>general specifications:<font color=''red''><b>ecs.g5.xlarge</b></font><br>note:
        a few zones do not support general specifications<br>see detail: <a href=''https://www.alibabacloud.com/help/en/doc-detail/25378.html''
        target=''_blank''><b><font color=''blue''>Instance Specification Family</font></a></b>'
      zh-cn: 填寫VSwitch可用性區域下可使用的規格;<br>通用規格:<font color='red'><b>ecs.g5.xlarge</b></font><br>註:可用性區域可能不支援通用規格<br>規格詳見:<a
        href='https://www.alibabacloud.com/help/document_detail/25378.html' target='_blank'><b><font
        color='blue'>執行個體規格類型系列</font></a></b>
    AssociationProperty: ALIYUN::ECS::Instance::InstanceType
    AssociationPropertyMetadata:
      ZoneId: VSwitchZoneId
  ECSImageId:
    Type: String
    Label:
      en: Application Server Image
      zh-cn: 應用服務鏡像
    Description:
      en: 'Server Instance Image ID. </b><br>[Shanghai:<font color=''green''>m-uf6j125b6mhvg27jo58a</font>]<br>[Hangzhou:<font
        color=''green''>m-bp1h0ys627i2ke0dx0t1</font>]<br>[Beijing:<font color=''green''>m-2zeir96eip2yw414w1jd</font>]<br>[Qingdao:<font
        color=''green''>m-m5e81ywnfuk84x1r7v0n</font>]<br>[Shenzhen:<font color=''green''>m-wz98u1criwvafhq3ctfm</font>]<br>[Zhangjiakou:<font
        color=''green''>m-8vbg3h5yp5ncag0q31lt</font>]<br>[Hohhot:<font color=''green''>m-hp34cnncgeiowbkzpmic</font>]<br>[Hong
        Kong:<font color=''green''>m-j6c0e5hkfmzk6d8bfss1</font>]<br>[US(Silincon
        Valley):<font color=''green''>m-rj981ywnfuk84x1r7v0p</font>]<br>note: for
        more images available, see detail: <b><a href=''https://marketplace.alibabacloud.com/products?keywords=magento''
        target=''_blank''><font color=''blue''>Magento Image</font></a></b>'
      zh-cn: 伺服器鏡像<br>雲市場鏡像名稱:《Magento開源電子商務系統 (LAMP|中文包)》<br><b>參考值:</b><br>[上海:<font
        color='green'>m-uf6j125b6mhvg27jo58a</font>]<br>[杭州:<font color='green'>m-bp1h0ys627i2ke0dx0t1</font>]<br>[北京:<font
        color='green'>m-2zeir96eip2yw414w1jd</font>]<br>[青島:<font color='green'>m-m5e81ywnfuk84x1r7v0n</font>]<br>[深圳:<font
        color='green'>m-wz98u1criwvafhq3ctfm</font>]<br>[張家口:<font color='green'>m-8vbg3h5yp5ncag0q31lt</font>]<br>[呼和浩特:<font
        color='green'>m-hp34cnncgeiowbkzpmic</font>]<br>[香港:<font color='green'>m-j6c0e5hkfmzk6d8bfss1</font>]<br>[美西1(矽谷):<font
        color='green'>m-rj981ywnfuk84x1r7v0p</font>]<br>註:更多可用性區域鏡像詳見:<b><a href='https://market.aliyun.com/products/53616009/cmjj00038197.html'
        target='_blank'><font color='blue'>Magento鏡像</font></a></b>
  SystemDiskCategory:
    Type: String
    Label:
      en: Disk Type
      zh-cn: 磁碟類型
    Description:
      en: '<font color=''blue''><b>Optional values:</b></font><br>[cloud_efficiency:
        <font color=''green''>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font color=''green''>SSD
        Cloud Disk</font>]<br>[cloud_essd: <font color=''green''>ESSD Cloud Disk</font>]<br>[cloud:
        <font color=''green''>Cloud Disk</font>]<br>[ephemeral_ssd: <font color=''green''>Local
        SSD Cloud Disk</font>]'
      zh-cn: '<font color=''blue''><b>可選值:</b></font><br>[cloud_efficiency: <font
        color=''green''>高效雲端硬碟</font>]<br>[cloud_ssd: <font color=''green''>SSD雲端硬碟</font>]<br>[cloud_essd:
        <font color=''green''>ESSD雲端硬碟</font>]<br>[cloud: <font color=''green''>普通雲端硬碟</font>]<br>[ephemeral_ssd:
        <font color=''green''>本地SSD盤</font>]'
    Default: cloud_efficiency
    AllowedValues:
    - cloud_efficiency
    - cloud_ssd
    - cloud
    - cloud_essd
    - ephemeral_ssd
  SystemDiskSize:
    Type: Number
    Label:
      en: System Disk Size
      zh-cn: 系統硬碟大小
    Description:
      en: 'System disk size, range of values: 40-500, units: GB.'
      zh-cn: 系統硬碟大小, 取值範圍:[40, 500], 單位:GB。
    ConstraintDescription:
      en: 'Value range: 40~500. Unit: GB.'
      zh-cn: 取值範圍:40~500。單位:GB。
    Default: 40
    MinValue: 40
    MaxValue: 500
  EcsPassword:
    Type: String
    Label:
      en: Login Password
      zh-cn: 登入密碼
    Description:
      en: Server login password, Length 8-30, must contain three(Capital letters,
        lowercase letters, numbers, ()`~!@#$%^&*_-+=| {}[]:;' <>,.? / Special symbol
        in).
      zh-cn: 伺服器登入密碼,長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符號)。
    ConstraintDescription:
      en: Length 8-30, must contain three(Capital letters, lowercase letters, numbers,
        ()`~!@#$%^&*_-+=| {}[]:;' <>,.? / Special symbol in).
      zh-cn: 長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符號)。
    AssociationProperty: 'ALIYUN::ECS::Instance::Password'
  LoadBalancerName:
    Type: String
    Label:
      en: Instance Name
      zh-cn: 執行個體名稱
    Description:
      en: 'Length: 1-80 characters. Can contain Chinese、letters、digits and special
        characters(''-''、''/''、''.''、''_'').'
      zh-cn: 長度限制為1-80個字元,允許包含中文、字母、數字、'-'、'/'、'.'、'_'這些字元
    Default: slb001
  LoadBalancerSpec:
    Type: String
    Label:
      en: Specifications
      zh-cn: 規格
    Description:
      en: Instance specifications,</br>see detail:</b><a href='https://www.alibabacloud.com/help/doc-detail/85939.html'
        target='_blank'><b><font color='blue'>Performance Support Type</b></font></a>
      zh-cn: 執行個體規格,</br>詳見:</b><a href='https://www.alibabacloud.com/help/document_detail/85939.html'
        target='_blank'><b><font color='blue'>效能保障型</b></font></a>
    Default: slb.s1.small
  DBInstanceEngineAndVersion:
    Type: String
    Label:
      en: Type And Version
      zh-cn: 類型與版本
    Description:
      en: Database type and version number.
      zh-cn: 資料庫類型與版本號碼。
    Default: MySQL-5.6
    AllowedValues:
    - MySQL-5.5
    - MySQL-5.6
    - MySQL-5.7
    - MySQL-8.0
  DBInstanceClass:
    Type: String
    Label:
      en: Specifications
      zh-cn: 規格
    Description:
      en: 'Select the instance specification based on the type of database engine
        and the available area support;<br>see detail: <a href=''https://www.alibabacloud.com/help/doc-detail/26312.html''
        target=''_blank''><b><font color=''blue''>Instance specification sheet</font></b></a>'
      zh-cn: 根據資料庫引擎的類型和可用的地區支援選擇執行個體規格;<br>請參見詳細資料:<a href='https://www.alibabacloud.com/help/document_detail/26312.html'
        target='_blank'><b><font color='blue'>執行個體規格表</font></b></a>
    Default: rds.mysql.s2.large
  DBInstanceStorage:
    Type: Number
    Label:
      en: Storage Space
      zh-cn: 儲存空間
    Description:
      en: 'Database storage space, unit: GB, increasing every 5GB, valid value: 5-1000.'
      zh-cn: 資料庫儲存空間, 單位:GB, 每5GB進行遞增,取值範圍:5-1000。
    ConstraintDescription:
      en: 'Database storage space, unit: GB, increasing every 5GB, valid value: 5-1000.'
      zh-cn: 資料庫儲存空間, 單位:GB, 每5GB進行遞增,取值範圍:5-1000。
    Default: 5
    MinValue: 5
    MaxValue: 1000
  RdsUserPassword:
    Type: String
    Label:
      en: Password
      zh-cn: 密碼
    Description:
      en: 'The primary account password for the database instance.Large/lowercase
        letters, Numbers and special characters take up three kinds, and the length
        is 8-32 bits. Special characters included! @ # $% ^ & * () _ + - ='
      zh-cn: 資料庫執行個體的主帳號密碼。大/小寫字母、數字、特殊字元佔三種,長度8-32位;特殊字元包含!@#$%^&*()_+-=
    AssociationProperty: ALIYUN::RDS::Instance::AccountPassword
    ConstraintDescription:
      en: 'Large/lowercase letters, Numbers and special characters take up three kinds,
        and the length is 8-32 bits. Special characters included! @ # $% ^ & * ()
        _ + - ='
      zh-cn: 大/小寫字母、數字、特殊字元佔三種,長度8-32位;特殊字元包含!@#$%^&*()_+-=
    MinLength: 8
    MaxLength: 32
    NoEcho: true
  DBName:
    Type: String
    Label:
      en: Database Name
      zh-cn: 資料庫名稱
    Description:
      en: Database name, consisting of lowercase letters, Numbers, and special characters
        (-_), starting with letters, ending with letters or Numbers, up to 64 characters.
      zh-cn: 資料庫名稱,由小寫字母、數字及特殊字元(-_)組成,以字母開頭,字母或數字結尾,最多64個字元。
    Default: db_magento
  RdsUserType:
    Type: String
    Label:
      en: Account Type
      zh-cn: 帳號類型
    Description:
      en: '<b>Database account type, <font color=''blue''>AllowedValues: </font></b><br>[Normal:
        <font color=''green''>Ordinary account</font>]<br>[Super: <font color=''green''>High-privilege
        account</font>]'
      zh-cn: '<b>資料庫帳號類型,<font color=''blue''>可選值:</font></b><br>[Normal: <font color=''green''>普通帳號</font>]<br>[Super:
        <font color=''green''>高許可權帳號</font>]'
    Default: Normal
    AllowedValues:
    - Super
    - Normal
  RdsUserName:
    Type: String
    Label:
      en: Database Account
      zh-cn: 資料庫帳號
    Description:
      en: Consists of lowercase letters, Numbers, and underscores, beginning with
        letters, ending with letters or Numbers, up to 16 characters, and at least
        2 characters.
      zh-cn: 由小寫字母,數字、底線組成,以字母開頭,字母或數字結尾,最多16個字元,最少2個字元。
    Default: account_magento
    MinLength: 2
    MaxLength: 16
Resources:
  Vpc:
    Type: ALIYUN::ECS::VPC
    Properties:
      CidrBlock:
        Ref: VpcCidrBlock
      VpcName:
        Fn::Join:
        - '-'
        - - Stack
          - Ref: ALIYUN::StackId
  SecurityGroup:
    Type: ALIYUN::ECS::SecurityGroup
    Properties:
      VpcId:
        Ref: Vpc
      SecurityGroupIngress:
      - IpProtocol: tcp
        Policy: accept
        PortRange: 3389/3389
        Priority: 1
        SourceCidrIp: 0.0.0.0/0
      Tags:
      - Key: best_practice
        Value: '065'
  VSwitch:
    Type: ALIYUN::ECS::VSwitch
    Properties:
      ZoneId:
        Ref: VSwitchZoneId
      VpcId:
        Ref: Vpc
      CidrBlock:
        Ref: VswCidrBlock
      VSwitchName:
        Fn::Join:
        - '-'
        - - Stack
          - Ref: ALIYUN::StackId
          - Fn::Select:
            - '2'
            - Fn::Split:
              - '-'
              - Ref: VSwitchZoneId
  ECS:
    Type: ALIYUN::ECS::Instance
    Properties:
      ZoneId:
        Ref: VSwitchZoneId
      VpcId:
        Ref: Vpc
      VSwitchId:
        Ref: VSwitch
      SecurityGroupId:
        Ref: SecurityGroup
      ImageId:
        Ref: ECSImageId
      AllocatePublicIP: true
      HostName: APP001
      InstanceName: APP001
      InstanceType:
        Ref: EcsInstanceType
      InternetChargeType: PayByTraffic
      Password:
        Ref: EcsPassword
      SystemDiskCategory:
        Ref: SystemDiskCategory
      SystemDiskSize:
        Ref: SystemDiskSize
      Tags:
      - Key: '065'
        Value: best_practice
  SLBLoadBalance:
    Type: ALIYUN::SLB::LoadBalancer
    Properties:
      VpcId:
        Ref: Vpc
      AddressType: internet
      InternetChargeType: paybytraffic
      LoadBalancerName:
        Ref: LoadBalancerName
      LoadBalancerSpec:
        Ref: LoadBalancerSpec
      MasterZoneId:
        Ref: VSwitchZoneId
      PayType: PayOnDemand
      SlaveZoneId:
        Ref: VSwitchZoneId2
      Tags:
      - Key: '065'
        Value: best_practice
  BackendServerAttachment:
    Type: ALIYUN::SLB::BackendServerAttachment
    Properties:
      BackendServerList:
      - Ref: ECS
      BackendServerWeightList:
      - 100
      LoadBalancerId:
        Ref: SLBLoadBalance
    DependsOn:
    - ECS
    - SLBLoadBalance
  Listener:
    Type: ALIYUN::SLB::Listener
    Properties:
      BackendServerPort: 80
      Bandwidth: -1
      ListenerPort: 80
      LoadBalancerId:
        Ref: SLBLoadBalance
      Protocol: http
    DependsOn: SLBLoadBalance
  RdsDBInstance:
    Type: ALIYUN::RDS::DBInstance
    Properties:
      VpcId:
        Ref: Vpc
      VSwitchId:
        Ref: VSwitch
      DBInstanceClass:
        Ref: DBInstanceClass
      DBInstanceStorage:
        Ref: DBInstanceStorage
      DBMappings:
      - CharacterSetName: utf8
        DBName:
          Ref: DBName
      Engine:
        Fn::Select:
        - '0'
        - Fn::Split:
          - '-'
          - Ref: DBInstanceEngineAndVersion
      EngineVersion:
        Fn::Select:
        - '1'
        - Fn::Split:
          - '-'
          - Ref: DBInstanceEngineAndVersion
      MasterUserPassword:
        Ref: RdsUserPassword
      MasterUserType:
        Ref: RdsUserType
      MasterUsername:
        Ref: RdsUserName
      MultiAZ: true
      SecurityIPList:
        Ref: VpcCidrBlock
      Tags:
        Key: best_practice
        Value: '065'
Outputs:
  ECSPublicIP:
    Description: Magento伺服器公網IP
    Value:
      Fn::GetAtt:
      - ECS
      - PublicIp
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
    - Parameters:
      - VpcCidrBlock
      - VSwitchZoneId
      - VswCidrBlock
      - VSwitchZoneId2
      - VswCidrBlock2
      Label:
        default: VPC
    - Parameters:
      - EcsInstanceType
      - ECSImageId
      - SystemDiskCategory
      - SystemDiskSize
      - EcsPassword
      Label:
        default: ECS
    - Parameters:
      - LoadBalancerName
      - LoadBalancerSpec
      Label:
        default: SLB
    - Parameters:
      - DBInstanceEngineAndVersion
      - DBInstanceClass
      - DBInstanceStorage
      - RdsUserPassword
      - DBName
      - RdsUserType
      - RdsUserName
      Label:
        default: RDS
    TemplateTags:
    - acs:solution:安全&合規:電商網站業務安全
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "建立電商網站防護方案,含VPC、ECS、SLB、RDS資源,確保穩定性與優惠真實性,跨可用性區域部署。",
    "en": "Develop an e-commerce website protection plan, encompassing Virtual Private Cloud (VPC), Elastic Compute Service (ECS), Server Load Balancer (SLB), and Relational Database Service (RDS) resources. Implement measures to prevent scalpers from exploiting promotions, ensuring service stability and the authenticity of discounts. Deploy across multiple availability zones for redundancy and high availability."
  },
  "Parameters": {
    "VpcCidrBlock": {
      "Type": "String",
      "Label": {
        "en": "VPC CIDR Block",
        "zh-cn": "專用網路網段"
      },
      "Description": {
        "en": "The IP address range of the VPC in the CIDR Block form; <br>You can use the following IP address ranges: <br><font color='green'>[10.0.0.0/8]</font><br><font color='green'>[172.16.0.0/12]</font><br><font color='green'>[192.168.0.0/16]</font>",
        "zh-cn": "專用網路IP位址區段範圍,<br>您可以使用以下的IP位址區段:<br><font color='green'>[10.0.0.0/8]</font><br><font color='green'>[172.16.0.0/12]</font><br><font color='green'>[192.168.0.0/16]</font>"
      },
      "Default": "192.168.0.0/16",
      "AllowedValues": [
        "10.0.0.0/8",
        "172.16.0.0/12",
        "192.168.0.0/16"
      ]
    },
    "VSwitchZoneId": {
      "Type": "String",
      "Label": {
        "en": "Master Zone",
        "zh-cn": "主可用性區域"
      },
      "Description": {
        "en": "Availability Zone ID;<br><b>note: <font color='blue'>before selecting the Available Zone, verify that the Available Zone supports the specification for creating SLB、RDS、ECS resources.</font></b>",
        "zh-cn": "可用性區域ID;<br><b>註: <font color='blue'>選擇可用性區域前請確認該可用性區域是否支援建立SLB、RDS、ECS資源的規格。</font></b>"
      },
      "AssociationProperty": "ALIYUN::ECS::Instance:ZoneId"
    },
    "VswCidrBlock": {
      "Type": "String",
      "Label": {
        "en": "Master Zone CIDR Block",
        "zh-cn": "主可用性區域網段"
      },
      "Description": {
        "en": "Must be a subnet segment that belongs to a proprietary network and is not occupied by another VSwitch.",
        "zh-cn": "必須是所屬專用網路的子網段,並且沒有被其他交換器佔用。"
      },
      "Default": "192.168.1.0/24"
    },
    "VSwitchZoneId2": {
      "Type": "String",
      "Label": {
        "en": "Slave Zone",
        "zh-cn": "備可用性區域"
      },
      "Description": {
        "en": "Availability Zone ID,<br><b>note: <font color='blue'>before selecting the Availability Zone, verify that the available zone supports the specification for creating SLB resources,not the same as Master Zone.</font></b>",
        "zh-cn": "可用性區域ID,<br><b>註: <font color='blue'>選擇可用性區域前請確認該可用性區域是否支援建立SLB資源的規格,並不同於主可用性區域。</font></b>"
      },
      "AssociationProperty": "ALIYUN::ECS::Instance:ZoneId"
    },
    "VswCidrBlock2": {
      "Type": "String",
      "Label": {
        "en": "Slave Zone CIDR Block",
        "zh-cn": "備可用性區域網段"
      },
      "Description": {
        "en": "Must be a subnet segment that belongs to a proprietary network and is not occupied by another VSwitch.",
        "zh-cn": "必須是所屬專用網路的子網段,並且沒有被其他交換器佔用。"
      },
      "Default": "192.168.2.0/24"
    },
    "EcsInstanceType": {
      "Type": "String",
      "Label": {
        "en": "Instance Type",
        "zh-cn": "執行個體規格"
      },
      "Description": {
        "en": "Fill in the specifications that can be used under the VSwitch availability zone;</b></font><br>general specifications:<font color='red'><b>ecs.g5.xlarge</b></font><br>note: a few zones do not support general specifications<br>see detail: <a href='https://www.alibabacloud.com/help/en/doc-detail/25378.html' target='_blank'><b><font color='blue'>Instance Specification Family</font></a></b>",
        "zh-cn": "填寫VSwitch可用性區域下可使用的規格;<br>通用規格:<font color='red'><b>ecs.g5.xlarge</b></font><br>註:可用性區域可能不支援通用規格<br>規格詳見:<a href='https://www.alibabacloud.com/help/document_detail/25378.html' target='_blank'><b><font color='blue'>執行個體規格類型系列</font></a></b>"
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "ZoneId": "VSwitchZoneId"
      }
    },
    "ECSImageId": {
      "Type": "String",
      "Label": {
        "en": "Application Server Image",
        "zh-cn": "應用服務鏡像"
      },
      "Description": {
        "en": "Server Instance Image ID. </b><br>[Shanghai:<font color='green'>m-uf6j125b6mhvg27jo58a</font>]<br>[Hangzhou:<font color='green'>m-bp1h0ys627i2ke0dx0t1</font>]<br>[Beijing:<font color='green'>m-2zeir96eip2yw414w1jd</font>]<br>[Qingdao:<font color='green'>m-m5e81ywnfuk84x1r7v0n</font>]<br>[Shenzhen:<font color='green'>m-wz98u1criwvafhq3ctfm</font>]<br>[Zhangjiakou:<font color='green'>m-8vbg3h5yp5ncag0q31lt</font>]<br>[Hohhot:<font color='green'>m-hp34cnncgeiowbkzpmic</font>]<br>[Hong Kong:<font color='green'>m-j6c0e5hkfmzk6d8bfss1</font>]<br>[US(Silincon Valley):<font color='green'>m-rj981ywnfuk84x1r7v0p</font>]<br>note: for more images available, see detail: <b><a href='https://marketplace.alibabacloud.com/products?keywords=magento' target='_blank'><font color='blue'>Magento Image</font></a></b>",
        "zh-cn": "伺服器鏡像<br>雲市場鏡像名稱:《Magento開源電子商務系統 (LAMP|中文包)》<br><b>參考值:</b><br>[上海:<font color='green'>m-uf6j125b6mhvg27jo58a</font>]<br>[杭州:<font color='green'>m-bp1h0ys627i2ke0dx0t1</font>]<br>[北京:<font color='green'>m-2zeir96eip2yw414w1jd</font>]<br>[青島:<font color='green'>m-m5e81ywnfuk84x1r7v0n</font>]<br>[深圳:<font color='green'>m-wz98u1criwvafhq3ctfm</font>]<br>[張家口:<font color='green'>m-8vbg3h5yp5ncag0q31lt</font>]<br>[呼和浩特:<font color='green'>m-hp34cnncgeiowbkzpmic</font>]<br>[香港:<font color='green'>m-j6c0e5hkfmzk6d8bfss1</font>]<br>[美西1(矽谷):<font color='green'>m-rj981ywnfuk84x1r7v0p</font>]<br>註:更多可用性區域鏡像詳見:<b><a href='https://market.aliyun.com/products/53616009/cmjj00038197.html' target='_blank'><font color='blue'>Magento鏡像</font></a></b>"
      }
    },
    "SystemDiskCategory": {
      "Type": "String",
      "Label": {
        "en": "Disk Type",
        "zh-cn": "磁碟類型"
      },
      "Description": {
        "en": "<font color='blue'><b>Optional values:</b></font><br>[cloud_efficiency: <font color='green'>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font color='green'>SSD Cloud Disk</font>]<br>[cloud_essd: <font color='green'>ESSD Cloud Disk</font>]<br>[cloud: <font color='green'>Cloud Disk</font>]<br>[ephemeral_ssd: <font color='green'>Local SSD Cloud Disk</font>]",
        "zh-cn": "<font color='blue'><b>可選值:</b></font><br>[cloud_efficiency: <font color='green'>高效雲端硬碟</font>]<br>[cloud_ssd: <font color='green'>SSD雲端硬碟</font>]<br>[cloud_essd: <font color='green'>ESSD雲端硬碟</font>]<br>[cloud: <font color='green'>普通雲端硬碟</font>]<br>[ephemeral_ssd: <font color='green'>本地SSD盤</font>]"
      },
      "Default": "cloud_efficiency",
      "AllowedValues": [
        "cloud_efficiency",
        "cloud_ssd",
        "cloud",
        "cloud_essd",
        "ephemeral_ssd"
      ]
    },
    "SystemDiskSize": {
      "Type": "Number",
      "Label": {
        "en": "System Disk Size",
        "zh-cn": "系統硬碟大小"
      },
      "Description": {
        "en": "System disk size, range of values: 40-500, units: GB.",
        "zh-cn": "系統硬碟大小, 取值範圍:[40, 500], 單位:GB。"
      },
      "ConstraintDescription": {
        "en": "Value range: 40~500. Unit: GB.",
        "zh-cn": "取值範圍:40~500。單位:GB。"
      },
      "Default": 40,
      "MinValue": 40,
      "MaxValue": 500
    },
    "EcsPassword": {
      "Type": "String",
      "Label": {
        "en": "Login Password",
        "zh-cn": "登入密碼"
      },
      "Description": {
        "en": "Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=| {}[]:;' <>,.? / Special symbol in).",
        "zh-cn": "伺服器登入密碼,長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符號)。"
      },
      "ConstraintDescription": {
        "en": "Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=| {}[]:;' <>,.? / Special symbol in).",
        "zh-cn": "長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符號)。"
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::Password"
    },
    "LoadBalancerName": {
      "Type": "String",
      "Label": {
        "en": "Instance Name",
        "zh-cn": "執行個體名稱"
      },
      "Description": {
        "en": "Length: 1-80 characters. Can contain Chinese、letters、digits and special characters('-'、'/'、'.'、'_').",
        "zh-cn": "長度限制為1-80個字元,允許包含中文、字母、數字、'-'、'/'、'.'、'_'這些字元"
      },
      "Default": "slb001"
    },
    "LoadBalancerSpec": {
      "Type": "String",
      "Label": {
        "en": "Specifications",
        "zh-cn": "規格"
      },
      "Description": {
        "en": "Instance specifications,</br>see detail:</b><a href='https://www.alibabacloud.com/help/doc-detail/85939.html' target='_blank'><b><font color='blue'>Performance Support Type</b></font></a>",
        "zh-cn": "執行個體規格,</br>詳見:</b><a href='https://www.alibabacloud.com/help/document_detail/85939.html' target='_blank'><b><font color='blue'>效能保障型</b></font></a>"
      },
      "Default": "slb.s1.small"
    },
    "DBInstanceEngineAndVersion": {
      "Type": "String",
      "Label": {
        "en": "Type And Version",
        "zh-cn": "類型與版本"
      },
      "Description": {
        "en": "Database type and version number.",
        "zh-cn": "資料庫類型與版本號碼。"
      },
      "Default": "MySQL-5.6",
      "AllowedValues": [
        "MySQL-5.5",
        "MySQL-5.6",
        "MySQL-5.7",
        "MySQL-8.0"
      ]
    },
    "DBInstanceClass": {
      "Type": "String",
      "Label": {
        "en": "Specifications",
        "zh-cn": "規格"
      },
      "Description": {
        "en": "Select the instance specification based on the type of database engine and the available area support;<br>see detail: <a href='https://www.alibabacloud.com/help/doc-detail/26312.html' target='_blank'><b><font color='blue'>Instance specification sheet</font></b></a>",
        "zh-cn": "根據資料庫引擎的類型和可用的地區支援選擇執行個體規格;<br>請參見詳細資料:<a href='https://www.alibabacloud.com/help/document_detail/26312.html' target='_blank'><b><font color='blue'>執行個體規格表</font></b></a>"
      },
      "Default": "rds.mysql.s2.large"
    },
    "DBInstanceStorage": {
      "Type": "Number",
      "Label": {
        "en": "Storage Space",
        "zh-cn": "儲存空間"
      },
      "Description": {
        "en": "Database storage space, unit: GB, increasing every 5GB, valid value: 5-1000.",
        "zh-cn": "資料庫儲存空間, 單位:GB, 每5GB進行遞增,取值範圍:5-1000。"
      },
      "ConstraintDescription": {
        "en": "Database storage space, unit: GB, increasing every 5GB, valid value: 5-1000.",
        "zh-cn": "資料庫儲存空間, 單位:GB, 每5GB進行遞增,取值範圍:5-1000。"
      },
      "Default": 5,
      "MinValue": 5,
      "MaxValue": 1000
    },
    "RdsUserPassword": {
      "Type": "String",
      "Label": {
        "en": "Password",
        "zh-cn": "密碼"
      },
      "Description": {
        "en": "The primary account password for the database instance.Large/lowercase letters, Numbers and special characters take up three kinds, and the length is 8-32 bits. Special characters included! @ # $% ^ & * () _ + - =",
        "zh-cn": "資料庫執行個體的主帳號密碼。大/小寫字母、數字、特殊字元佔三種,長度8-32位;特殊字元包含!@#$%^&*()_+-="
      },
      "AssociationProperty": "ALIYUN::RDS::Instance::AccountPassword",
      "ConstraintDescription": {
        "en": "Large/lowercase letters, Numbers and special characters take up three kinds, and the length is 8-32 bits. Special characters included! @ # $% ^ & * () _ + - =",
        "zh-cn": "大/小寫字母、數字、特殊字元佔三種,長度8-32位;特殊字元包含!@#$%^&*()_+-="
      },
      "MinLength": 8,
      "MaxLength": 32,
      "NoEcho": true
    },
    "DBName": {
      "Type": "String",
      "Label": {
        "en": "Database Name",
        "zh-cn": "資料庫名稱"
      },
      "Description": {
        "en": "Database name, consisting of lowercase letters, Numbers, and special characters (-_), starting with letters, ending with letters or Numbers, up to 64 characters.",
        "zh-cn": "資料庫名稱,由小寫字母、數字及特殊字元(-_)組成,以字母開頭,字母或數字結尾,最多64個字元。"
      },
      "Default": "db_magento"
    },
    "RdsUserType": {
      "Type": "String",
      "Label": {
        "en": "Account Type",
        "zh-cn": "帳號類型"
      },
      "Description": {
        "en": "<b>Database account type, <font color='blue'>AllowedValues: </font></b><br>[Normal: <font color='green'>Ordinary account</font>]<br>[Super: <font color='green'>High-privilege account</font>]",
        "zh-cn": "<b>資料庫帳號類型,<font color='blue'>可選值:</font></b><br>[Normal: <font color='green'>普通帳號</font>]<br>[Super: <font color='green'>高許可權帳號</font>]"
      },
      "Default": "Normal",
      "AllowedValues": [
        "Super",
        "Normal"
      ]
    },
    "RdsUserName": {
      "Type": "String",
      "Label": {
        "en": "Database Account",
        "zh-cn": "資料庫帳號"
      },
      "Description": {
        "en": "Consists of lowercase letters, Numbers, and underscores, beginning with letters, ending with letters or Numbers, up to 16 characters, and at least 2 characters.",
        "zh-cn": "由小寫字母,數字、底線組成,以字母開頭,字母或數字結尾,最多16個字元,最少2個字元。"
      },
      "Default": "account_magento",
      "MinLength": 2,
      "MaxLength": 16
    }
  },
  "Resources": {
    "Vpc": {
      "Type": "ALIYUN::ECS::VPC",
      "Properties": {
        "CidrBlock": {
          "Ref": "VpcCidrBlock"
        },
        "VpcName": {
          "Fn::Join": [
            "-",
            [
              "Stack",
              {
                "Ref": "ALIYUN::StackId"
              }
            ]
          ]
        }
      }
    },
    "SecurityGroup": {
      "Type": "ALIYUN::ECS::SecurityGroup",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "SecurityGroupIngress": [
          {
            "IpProtocol": "tcp",
            "Policy": "accept",
            "PortRange": "3389/3389",
            "Priority": 1,
            "SourceCidrIp": "0.0.0.0/0"
          }
        ],
        "Tags": [
          {
            "Key": "best_practice",
            "Value": "065"
          }
        ]
      }
    },
    "VSwitch": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "ZoneId": {
          "Ref": "VSwitchZoneId"
        },
        "VpcId": {
          "Ref": "Vpc"
        },
        "CidrBlock": {
          "Ref": "VswCidrBlock"
        },
        "VSwitchName": {
          "Fn::Join": [
            "-",
            [
              "Stack",
              {
                "Ref": "ALIYUN::StackId"
              },
              {
                "Fn::Select": [
                  "2",
                  {
                    "Fn::Split": [
                      "-",
                      {
                        "Ref": "VSwitchZoneId"
                      }
                    ]
                  }
                ]
              }
            ]
          ]
        }
      }
    },
    "ECS": {
      "Type": "ALIYUN::ECS::Instance",
      "Properties": {
        "ZoneId": {
          "Ref": "VSwitchZoneId"
        },
        "VpcId": {
          "Ref": "Vpc"
        },
        "VSwitchId": {
          "Ref": "VSwitch"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroup"
        },
        "ImageId": {
          "Ref": "ECSImageId"
        },
        "AllocatePublicIP": true,
        "HostName": "APP001",
        "InstanceName": "APP001",
        "InstanceType": {
          "Ref": "EcsInstanceType"
        },
        "InternetChargeType": "PayByTraffic",
        "Password": {
          "Ref": "EcsPassword"
        },
        "SystemDiskCategory": {
          "Ref": "SystemDiskCategory"
        },
        "SystemDiskSize": {
          "Ref": "SystemDiskSize"
        },
        "Tags": [
          {
            "Key": "065",
            "Value": "best_practice"
          }
        ]
      }
    },
    "SLBLoadBalance": {
      "Type": "ALIYUN::SLB::LoadBalancer",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "AddressType": "internet",
        "InternetChargeType": "paybytraffic",
        "LoadBalancerName": {
          "Ref": "LoadBalancerName"
        },
        "LoadBalancerSpec": {
          "Ref": "LoadBalancerSpec"
        },
        "MasterZoneId": {
          "Ref": "VSwitchZoneId"
        },
        "PayType": "PayOnDemand",
        "SlaveZoneId": {
          "Ref": "VSwitchZoneId2"
        },
        "Tags": [
          {
            "Key": "065",
            "Value": "best_practice"
          }
        ]
      }
    },
    "BackendServerAttachment": {
      "Type": "ALIYUN::SLB::BackendServerAttachment",
      "Properties": {
        "BackendServerList": [
          {
            "Ref": "ECS"
          }
        ],
        "BackendServerWeightList": [
          100
        ],
        "LoadBalancerId": {
          "Ref": "SLBLoadBalance"
        }
      },
      "DependsOn": [
        "ECS",
        "SLBLoadBalance"
      ]
    },
    "Listener": {
      "Type": "ALIYUN::SLB::Listener",
      "Properties": {
        "BackendServerPort": 80,
        "Bandwidth": -1,
        "ListenerPort": 80,
        "LoadBalancerId": {
          "Ref": "SLBLoadBalance"
        },
        "Protocol": "http"
      },
      "DependsOn": "SLBLoadBalance"
    },
    "RdsDBInstance": {
      "Type": "ALIYUN::RDS::DBInstance",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "VSwitchId": {
          "Ref": "VSwitch"
        },
        "DBInstanceClass": {
          "Ref": "DBInstanceClass"
        },
        "DBInstanceStorage": {
          "Ref": "DBInstanceStorage"
        },
        "DBMappings": [
          {
            "CharacterSetName": "utf8",
            "DBName": {
              "Ref": "DBName"
            }
          }
        ],
        "Engine": {
          "Fn::Select": [
            "0",
            {
              "Fn::Split": [
                "-",
                {
                  "Ref": "DBInstanceEngineAndVersion"
                }
              ]
            }
          ]
        },
        "EngineVersion": {
          "Fn::Select": [
            "1",
            {
              "Fn::Split": [
                "-",
                {
                  "Ref": "DBInstanceEngineAndVersion"
                }
              ]
            }
          ]
        },
        "MasterUserPassword": {
          "Ref": "RdsUserPassword"
        },
        "MasterUserType": {
          "Ref": "RdsUserType"
        },
        "MasterUsername": {
          "Ref": "RdsUserName"
        },
        "MultiAZ": true,
        "SecurityIPList": {
          "Ref": "VpcCidrBlock"
        },
        "Tags": {
          "Key": "best_practice",
          "Value": "065"
        }
      }
    }
  },
  "Outputs": {
    "ECSPublicIP": {
      "Description": "Magento伺服器公網IP",
      "Value": {
        "Fn::GetAtt": [
          "ECS",
          "PublicIp"
        ]
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "VpcCidrBlock",
            "VSwitchZoneId",
            "VswCidrBlock",
            "VSwitchZoneId2",
            "VswCidrBlock2"
          ],
          "Label": {
            "default": "VPC"
          }
        },
        {
          "Parameters": [
            "EcsInstanceType",
            "ECSImageId",
            "SystemDiskCategory",
            "SystemDiskSize",
            "EcsPassword"
          ],
          "Label": {
            "default": "ECS"
          }
        },
        {
          "Parameters": [
            "LoadBalancerName",
            "LoadBalancerSpec"
          ],
          "Label": {
            "default": "SLB"
          }
        },
        {
          "Parameters": [
            "DBInstanceEngineAndVersion",
            "DBInstanceClass",
            "DBInstanceStorage",
            "RdsUserPassword",
            "DBName",
            "RdsUserType",
            "RdsUserName"
          ],
          "Label": {
            "default": "RDS"
          }
        }
      ],
      "TemplateTags": [
        "acs:solution:安全&合規:電商網站業務安全"
      ]
    }
  }
}

更多樣本,請參考包含此資源的公用模板