Todos os produtos
Search
Central de documentação

Resource Orchestration Service:ALIYUN::SLB::LoadBalancer

Última atualização: Jun 27, 2026

Cria uma instância do Server Load Balancer (SLB).

Sintaxe

{
  "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
  }
}

Propriedades

Nome da propriedade

Tipo

Obrigatório

Atualização permitida

Descrição

Restrição

ResourceGroupId

String

Não

Sim

ID do grupo de recursos.

Nenhuma

DeletionProtection

Boolean

Não

Sim

Ativa a proteção contra exclusão.

Valores válidos:

  • true: ativa a proteção contra exclusão.

  • false (padrão): desativa a proteção contra exclusão.

VpcId

String

Não

Não

ID da VPC.

Nenhuma

SlaveZoneId

String

Não

Não

ID da zona secundária da instância SLB.

Nenhuma

Bandwidth

Integer

Não

Sim

Largura de banda de pico para instâncias públicas com faturamento por largura de banda.

Valores válidos: 1 a 10000.

Unidade: Mbit/s.

Valor padrão: 1.

Instâncias em VPC usam pagamento por transferência de dados como padrão.

  • Pagamento por largura de banda: aloque largura de banda para cada listener por meio do parâmetro Bandwidth do listener antes que a configuração tenha efeito.

  • Pagamento por transferência de dados: defina a largura de banda de pico diretamente em cada listener. Esta propriedade é ignorada.

AddressType

String

Não

Não

Tipo de endereço da instância SLB.

Valores válidos:

  • internet (padrão): atribui um endereço IP público. O nome de domínio resolve para o endereço IP público. Acessível pela Internet.

  • intranet: atribui apenas um endereço IP privado. O nome de domínio resolve para o endereço IP privado. Acessível apenas dentro da mesma VPC.

VSwitchId

String

Não

Não

ID do vSwitch.

Nenhuma

LoadBalancerName

String

Não

Sim

Nome da instância SLB.

Comprimento: 1 a 80 caracteres. Caracteres válidos incluem letras, dígitos, hifens (-), barras (/), pontos (.) e sublinhados (_).

O padrão é um nome atribuído pelo sistema.

InternetChargeType

String

Não

Sim

Método de faturamento para instâncias públicas.

Valores válidos:

  • paybybandwidth: pagamento por largura de banda.

  • paybytraffic (padrão): pagamento por transferência de dados.

MasterZoneId

String

Não

Não

ID da zona primária da instância.

Nenhuma

Tags

List

Não

Sim

Tags da instância SLB.

É possível adicionar até cinco tags.

Propriedade Tags.

LoadBalancerSpec

String

Não

Sim

Especificação da instância SLB.

Valores válidos:

  • slb.s1.small (padrão)

  • slb.s2.small

  • slb.s2.medium

  • slb.s3.small

  • slb.s3.medium

  • slb.s3.large

  • slb.s3.xlarge

  • slb.s3.xxlarge

As especificações disponíveis variam conforme a região. instância de desempenho garantido.

ModificationProtectionStatus

String

Não

Sim

Status de proteção contra modificação.

Valores válidos:

  • NonProtection (padrão): desativa a proteção contra modificação.

  • ConsoleProtection: permite modificações pelo console.

ModificationProtectionReason

String

Não

Sim

Motivo para ativar a proteção contra modificação.

Comprimento: 1 a 80 caracteres. Deve começar com uma letra ou caractere chinês. Caracteres válidos incluem letras, caracteres chineses, dígitos, pontos (.) e hifens (-).

AddressIPVersion

String

Não

Não

Versão do IP.

Valores válidos:

  • ipv4

  • ipv6

    Nota

    Se você especificar ipv6, verifique as regiões suportadas e os limites.

InstanceChargeType

String

Não

Sim

Método de faturamento da instância.

Valores válidos:

  • PayBySpec (padrão): pagamento por especificação.

  • PayByCLCU: pagamento por LCU (Load Balancer Capacity Unit).

Sintaxe de Tags

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

Propriedade Tags

Nome da propriedade

Tipo

Obrigatório

Atualização permitida

Descrição

Restrição

Key

String

Sim

Não

Chave da tag.

Comprimento: 1 a 64 caracteres. Não pode começar com aliyun ou acs:. Não pode conter http:// ou https://.

Value

String

Não

Não

Valor da tag.

Comprimento: 0 a 128 caracteres. Não pode começar com aliyun ou acs:. Não pode conter http:// ou https://.

Valores de retorno

Fn::GetAtt

  • LoadBalancerId: ID da instância SLB.

  • NetworkType: tipo de rede da instância SLB.

  • AddressType: tipo de endereço da instância SLB.

  • IpAddress: endereço IP da instância SLB.

  • OrderId: ID do pedido.

  • Bandwidth: largura de banda de pico.

  • AddressIPVersion: versão do IP da instância SLB.

  • SlaveZoneId: ID da zona secundária da instância SLB.

  • MasterZoneId: ID da zona primária da instância SLB.

  • LoadBalancerName: nome da instância SLB.

  • ResourceGroupId: ID do grupo de recursos.

  • LoadBalancerSpec: especificação da instância SLB.

  • VpcId: ID da VPC da instância SLB.

  • VSwitchId: ID do vSwitch da instância SLB.

  • PayType: método de faturamento da instância.

Exemplos

Cenário 1: Crie uma instância SLB.

Criação rápida

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": {
  }
}

Cenário 2: Crie um grupo de instâncias ECS e anexe-o a uma instância SLB.

Criação rápida

ROSTemplateFormatVersion: '2015-09-01'
Description:
  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
    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
    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": {
    "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"
      },
      "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"
      },
      "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"
        ]
      }
    }
  }
}

Cenário 3: Crie um plano de proteção para site de e-commerce.

Criação rápida

ROSTemplateFormatVersion: '2015-09-01'
Description:
  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
    Description:
      en: 'The IP address range of the VPC in the CIDR Block form; 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>'
    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
    Description:
      en: 'Availability Zone ID;<br><b>Note: <font color=''blue''>Before selecting an availability zone, verify that it supports the required specifications for creating SLB, RDS and ECS resources.</font>'
    AssociationProperty: ALIYUN::ECS::Instance:ZoneId
  VswCidrBlock:
    Type: String
    Label:
      en: Master Zone CIDR Block
    Description:
      en: Must be a subnet segment that belongs to the VPC and is not occupied by another vSwitch.
    Default: 192.168.1.0/24
  VSwitchZoneId2:
    Type: String
    Label:
      en: Slave Zone
    Description:
      en: 'Availability Zone ID,<b>Note: <font color=''blue''>Before selecting an availability zone, verify that it supports the required specifications for creating SLB resources and differs from the primary zone.</font>'
    AssociationProperty: ALIYUN::ECS::Instance:ZoneId
  VswCidrBlock2:
    Type: String
    Label:
      en: Slave Zone CIDR Block
    Description:
      en: Must be a subnet segment that belongs to the VPC and is not occupied by another vSwitch.
    Default: 192.168.2.0/24
  EcsInstanceType:
    Type: String
    Label:
      en: Instance Type
    Description:
      en: 'Enter the instance types available in the vSwitch availability zone.</b></font>General-purpose instance types: <font color=''red''><b>ecs.g5.xlarge</font>Note: Some zones do not support general-purpose instance types.<br>For details, see <a href=''https://www.alibabacloud.com/help/en/doc-detail/25378.html'' target=''_blank''><b><font color=''blue''>Instance family</font></a>'
    AssociationProperty: ALIYUN::ECS::Instance::InstanceType
    AssociationPropertyMetadata:
      ZoneId: VSwitchZoneId
  ECSImageId:
    Type: String
    Label:
      en: Application Server Image
    Description:
      en: 'Server instance image ID. </b>[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 (Silicon Valley): <font color=''green''>m-rj981ywnfuk84x1r7v0p</font>]<br>Note: For more images, see <b><a href=''https://marketplace.alibabacloud.com/products?keywords=magento'' target=''_blank''><font color=''blue''>Magento image</font></a>'
  SystemDiskCategory:
    Type: String
    Label:
      en: Disk Type
    Description:
      en: '<font color=''blue''>Valid values:</font>[cloud_efficiency: <font color=''green''>Ultra disk</font>]<br>[cloud_ssd: <font color=''green''>Standard SSD</font>]<br>[cloud_essd: <font color=''green''>Enterprise SSD</font>]<br>[cloud: <font color=''green''>Basic disk</font>]<br>[ephemeral_ssd: <font color=''green''>Local SSD</font>]'
    Default: cloud_efficiency
    AllowedValues:
    - cloud_efficiency
    - cloud_ssd
    - cloud
    - cloud_essd
    - ephemeral_ssd
  SystemDiskSize:
    Type: Number
    Label:
      en: System Disk Size
    Description:
      en: 'System disk size. Valid values: 40 to 500. Unit: GB.'
    ConstraintDescription:
      en: 'Valid values: 40 to 500. Unit: GB.'
    Default: 40
    MinValue: 40
    MaxValue: 500
  EcsPassword:
    Type: String
    Label:
      en: Login Password
    Description:
      en: 'Server logon password. Length: 8 to 30 characters. Must contain at least three of the following: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=| {}[]:;' <>,.? / .'
    ConstraintDescription:
      en: 'Length: 8 to 30 characters. Must contain at least three of the following: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=| {}[]:;' <>,.? / .'
    AssociationProperty: 'ALIYUN::ECS::Instance::Password'
  LoadBalancerName:
    Type: String
    Label:
      en: Instance Name
    Description:
      en: 'Length: 1 to 80 characters. Valid characters include letters, digits, hyphens (-), forward slashes (/), periods (.), and underscores (_).'
    Default: slb001
  LoadBalancerSpec:
    Type: String
    Label:
      en: Specifications
    Description:
      en: 'Instance specifications.</br>For details, see <a href=''https://www.alibabacloud.com/help/doc-detail/85939.html'' target=''_blank''><b><font color=''blue''>Guaranteed-performance instance</font></a>'
    Default: slb.s1.small
  DBInstanceEngineAndVersion:
    Type: String
    Label:
      en: Type And Version
    Description:
      en: Database engine type and version number.
    Default: MySQL-5.6
    AllowedValues:
    - MySQL-5.5
    - MySQL-5.6
    - MySQL-5.7
    - MySQL-8.0
  DBInstanceClass:
    Type: String
    Label:
      en: Specifications
    Description:
      en: 'Select the instance specification based on the database engine type and region support.For details, see <a href=''https://www.alibabacloud.com/help/doc-detail/26312.html'' target=''_blank''><b><font color=''blue''>Instance specification sheet</font></a>'
    Default: rds.mysql.s2.large
  DBInstanceStorage:
    Type: Number
    Label:
      en: Storage Space
    Description:
      en: 'Database storage space. Unit: GB. Increments: 5 GB. Valid values: 5 to 1000.'
    ConstraintDescription:
      en: 'Database storage space. Unit: GB. Increments: 5 GB. Valid values: 5 to 1000.'
    Default: 5
    MinValue: 5
    MaxValue: 1000
  RdsUserPassword:
    Type: String
    Label:
      en: Password
    Description:
      en: 'The privileged account password for the database instance. Must contain at least three of the following: uppercase letters, lowercase letters, digits, and special characters !@#$%^&*()_+-=. Length: 8 to 32 characters.'
    AssociationProperty: ALIYUN::RDS::Instance::AccountPassword
    ConstraintDescription:
      en: 'Must contain at least three of the following: uppercase letters, lowercase letters, digits, and special characters !@#$%^&*()_+-=. Length: 8 to 32 characters.'
    MinLength: 8
    MaxLength: 32
    NoEcho: true
  DBName:
    Type: String
    Label:
      en: Database Name
    Description:
      en: 'Database name. Consists of lowercase letters, digits, and hyphens (-) or underscores (_). Must start with a letter and end with a letter or digit. Maximum length: 64 characters.'
    Default: db_magento
  RdsUserType:
    Type: String
    Label:
      en: Account Type
    Description:
      en: 'Database account type. <font color=''blue''>Valid values:</font>[Normal: <font color=''green''>Standard account</font>]<br>[Super: <font color=''green''>Privileged account</font>]'
    Default: Normal
    AllowedValues:
    - Super
    - Normal
  RdsUserName:
    Type: String
    Label:
      en: Database Account
    Description:
      en: 'Database account name. Consists of lowercase letters, digits, and underscores (_). Must start with a letter and end with a letter or digit. Length: 2 to 16 characters.'
    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: Public IP address of the Magento server
    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:security&compliance:e-commerce website business security
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "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"
      },
      "Description": {
        "en": "The IP address range of the VPC in the CIDR Block form; 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>"
      },
      "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"
      },
      "Description": {
        "en": "Availability Zone ID;<br><b>Note: <font color='blue'>Before selecting an availability zone, verify that it supports the required specifications for creating SLB, RDS, ECS resources.</font>"
      },
      "AssociationProperty": "ALIYUN::ECS::Instance:ZoneId"
    },
    "VswCidrBlock": {
      "Type": "String",
      "Label": {
        "en": "Master Zone CIDR Block"
      },
      "Description": {
        "en": "Must be a subnet segment that belongs to a proprietary network and is not occupied by another vSwitch."
      },
      "Default": "192.168.1.0/24"
    },
    "VSwitchZoneId2": {
      "Type": "String",
      "Label": {
        "en": "Slave Zone"
      },
      "Description": {
        "en": "Availability Zone ID,<b>Note: <font color='blue'>Before selecting an availability zone, verify that it supports the required specifications for creating SLB resources, not the same as the primary zone.</font>"
      },
      "AssociationProperty": "ALIYUN::ECS::Instance:ZoneId"
    },
    "VswCidrBlock2": {
      "Type": "String",
      "Label": {
        "en": "Slave Zone CIDR Block"
      },
      "Description": {
        "en": "Must be a subnet segment that belongs to a proprietary network and is not occupied by another vSwitch."
      },
      "Default": "192.168.2.0/24"
    },
    "EcsInstanceType": {
      "Type": "String",
      "Label": {
        "en": "Instance Type"
      },
      "Description": {
        "en": "Fill in the specifications that can be used under the vSwitch availability zone;</b></font>general-purpose instance types: <font color='red'><b>ecs.g5.xlarge</font>note: a few zones do not support general-purpose instance types<br>see detail: <a href='https://www.alibabacloud.com/help/en/doc-detail/25378.html' target='_blank'><b><font color='blue'>Instance family</font></a>"
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "ZoneId": "VSwitchZoneId"
      }
    },
    "ECSImageId": {
      "Type": "String",
      "Label": {
        "en": "Application Server Image"
      },
      "Description": {
        "en": "Server instance image ID. </b>[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>"
      }
    },
    "SystemDiskCategory": {
      "Type": "String",
      "Label": {
        "en": "Disk Type"
      },
      "Description": {
        "en": "<font color='blue'>Valid values:</font>[cloud_efficiency: <font color='green'>Ultra disk</font>]<br>[cloud_ssd: <font color='green'>Standard SSD</font>]<br>[cloud_essd: <font color='green'>Enterprise SSD</font>]<br>[cloud: <font color='green'>Basic disk</font>]<br>[ephemeral_ssd: <font color='green'>Local SSD</font>]"
      },
      "Default": "cloud_efficiency",
      "AllowedValues": [
        "cloud_efficiency",
        "cloud_ssd",
        "cloud",
        "cloud_essd",
        "ephemeral_ssd"
      ]
    },
    "SystemDiskSize": {
      "Type": "Number",
      "Label": {
        "en": "System Disk Size"
      },
      "Description": {
        "en": "System disk size, range of values: 40-500, units: GB."
      },
      "ConstraintDescription": {
        "en": "Valid values: 40 to 500. Unit: GB."
      },
      "Default": 40,
      "MinValue": 40,
      "MaxValue": 500
    },
    "EcsPassword": {
      "Type": "String",
      "Label": {
        "en": "Login Password"
      },
      "Description": {
        "en": "Server logon password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=| {}[]:;' <>,.? / Special symbol in)."
      },
      "ConstraintDescription": {
        "en": "Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=| {}[]:;' <>,.? / Special symbol in)."
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::Password"
    },
    "LoadBalancerName": {
      "Type": "String",
      "Label": {
        "en": "Instance Name"
      },
      "Description": {
        "en": "Length: 1-80 characters. Can contain Chinese, letters, digits and special characters('-', '/', '.', '_')."
      },
      "Default": "slb001"
    },
    "LoadBalancerSpec": {
      "Type": "String",
      "Label": {
        "en": "Specifications"
      },
      "Description": {
        "en": "Instance specifications,</br>see detail: <a href='https://www.alibabacloud.com/help/doc-detail/85939.html' target='_blank'><font color='blue'>Guaranteed-performance instance</font></a>"
      },
      "Default": "slb.s1.small"
    },
    "DBInstanceEngineAndVersion": {
      "Type": "String",
      "Label": {
        "en": "Type And Version"
      },
      "Description": {
        "en": "Database type and version number."
      },
      "Default": "MySQL-5.6",
      "AllowedValues": [
        "MySQL-5.5",
        "MySQL-5.6",
        "MySQL-5.7",
        "MySQL-8.0"
      ]
    },
    "DBInstanceClass": {
      "Type": "String",
      "Label": {
        "en": "Specifications"
      },
      "Description": {
        "en": "Select the instance specification based on the type of database engine and the available area support;see detail: <a href='https://www.alibabacloud.com/help/doc-detail/26312.html' target='_blank'><b><font color='blue'>Instance specification sheet</font></a>"
      },
      "Default": "rds.mysql.s2.large"
    },
    "DBInstanceStorage": {
      "Type": "Number",
      "Label": {
        "en": "Storage Space"
      },
      "Description": {
        "en": "Database storage space, unit: GB, increasing every 5GB, valid value: 5-1000."
      },
      "ConstraintDescription": {
        "en": "Database storage space, unit: GB, increasing every 5GB, valid value: 5-1000."
      },
      "Default": 5,
      "MinValue": 5,
      "MaxValue": 1000
    },
    "RdsUserPassword": {
      "Type": "String",
      "Label": {
        "en": "Password"
      },
      "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! @ # $% ^ & * () _ + - ="
      },
      "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! @ # $% ^ & * () _ + - ="
      },
      "MinLength": 8,
      "MaxLength": 32,
      "NoEcho": true
    },
    "DBName": {
      "Type": "String",
      "Label": {
        "en": "Database Name"
      },
      "Description": {
        "en": "Database name, consisting of lowercase letters, Numbers, and special characters (-_), starting with letters, ending with letters or Numbers, up to 64 characters."
      },
      "Default": "db_magento"
    },
    "RdsUserType": {
      "Type": "String",
      "Label": {
        "en": "Account Type"
      },
      "Description": {
        "en": "Database account type, <font color='blue'>Valid values: </font>[Normal: <font color='green'>Standard account</font>]<br>[Super: <font color='green'>Privileged account</font>]"
      },
      "Default": "Normal",
      "AllowedValues": [
        "Super",
        "Normal"
      ]
    },
    "RdsUserName": {
      "Type": "String",
      "Label": {
        "en": "Database Account"
      },
      "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."
      },
      "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": "Public IP address of the Magento server",
      "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:security&compliance:e-commerce website business security"
      ]
    }
  }
}

Consulte modelos públicos que incluem este recurso.