Todos os produtos
Search
Central de documentação

Resource Orchestration Service:ALIYUN::ECS::Route

Última atualização: Jun 27, 2026

O tipo de recurso ALIYUN::ECS::Route cria entradas de rota personalizadas.

Sintaxe

{
  "Type": "ALIYUN::ECS::Route",
  "Properties": {
    "DestinationCidrBlock": String,
    "RouteTableId": String,
    "NextHopId": String,
    "NextHopType": String,
    "NextHopList": List
  }
}

Propriedades

Nome da propriedade

Tipo

Obrigatório

Atualizável

Descrição

Restrições

DestinationCidrBlock

String

Sim

Não

Bloco CIDR de destino da entrada de rota personalizada.

Aceita IPv4, IPv6, blocos CIDR de destino de listas de prefixos e IDs de instância de listas de prefixos. Requisitos:

  • O bloco CIDR de destino não pode apontar para 100.64.0.0/10 nem estar contido nesse intervalo.

  • Entradas de rota diferentes na mesma tabela de rotas não podem ter o mesmo bloco CIDR de destino.

RouteTableId

String

Sim

Não

ID da tabela de rotas à qual a entrada de rota personalizada será adicionada.

Nenhuma

NextHopId

String

Não

Não

ID da instância do próximo salto da entrada de rota personalizada.

Se você definir NextHopType como Ecr, obtenha o AssociationId como ID do próximo salto usando a interface DescribeExpressConnectRouterAssociation.

NextHopType

String

Não

Não

Tipo de próximo salto da entrada de rota personalizada.

Valores:

  • Instance (padrão): instância ECS.

  • HaVip: IP virtual de alta disponibilidade.

  • RouterInterface: interface de roteador.

  • NetworkInterface: Elastic Network Interface (ENI).

  • VpnGateway: VPN Gateway.

  • IPv6Gateway: IPv6 Gateway.

  • NatGateway: NAT Gateway.

  • Attachment: TransitRouter.

  • VpcPeer: conexão de peering de VPC.

  • Ipv4Gateway: gateway IPv4.

  • GatewayEndpoint: endpoint de gateway.

  • Ecr: Express Connect Router (ECR).

  • GatewayLoadBalancerEndpoint: endpoint do Gateway Load Balancer (GWLBe).

NextHopList

List

Não

Não

Lista de próximos saltos da entrada de rota personalizada.

Ao especificar NextHopList, a entrada de rota torna-se uma entrada de rota ECMP. O número de entradas filhas deve ser menor ou igual a 16.

Para mais informações, consulte Propriedades de NextHopList.

Sintaxe de NextHopList

"NextHopList": [
  {
    "NextHopId": String,
    "NextHopType": String
  }
]

Propriedades de NextHopList

Nome da propriedade

Tipo

Obrigatório

Atualizável

Descrição

Restrições

NextHopId

String

Sim

Não

ID da instância do próximo salto da entrada de rota ECMP.

Nenhuma

NextHopType

String

Não

Não

Tipo de próximo salto da entrada de rota ECMP.

Valor: RouterInterface, que indica uma interface de roteador.

Valores de retorno

Fn::GetAtt

RouteEntryId: o ID da entrada de rota personalizada.

Exemplos

Cenário 1: Criar uma entrada de rota personalizada.

Criação rápida

ROSTemplateFormatVersion: '2015-09-01'
Resources:
  ECSRoute:
    Type: ALIYUN::ECS::Route
    Properties:
      RouteTableId: vtb-25oud****
      DestinationCidrBlock: 172.16.XX.XX/24
      NextHopId: i-25xzy****
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Resources": {
    "ECSRoute": {
      "Type": "ALIYUN::ECS::Route",
      "Properties": {
        "RouteTableId": "vtb-25oud****",
        "DestinationCidrBlock": "172.16.XX.XX/24",
        "NextHopId": "i-25xzy****"
      }
    }
  }
}

Cenário 2: Criar uma rota de conexão de peering de VPC.

Criação rápida

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  DestinationCidrBlock:
    Required: true
    Type: String
    Description:
      en: The RouteEntry's target network segment.
    Label:
      en: DestinationCidrBlock
  RouteTableId:
    Required: true
    Type: String
    Description:
      en: RouteTableId of created route entry.
    Label:
      en: RouteTableId
  NextHopType:
    Default: Instance
    Required: false
    Type: String
    Description:
      en: The next hop type. Now support 'Instance|HaVip|RouterInterface|NetworkInterface|VpnGateway|IPv6Gateway|NatGateway|Attachment'. The default value is Instance.When the NextHopList is specified, the value will be ignored.
    Label:
      en: NextHopType
  NextHopId:
    Default: Null
    Required: false
    Type: String
    Description:
      en: The route entry's next hop. When the NextHopList is specified, the value will be ignored.
    Label:
      en: NextHopId
  NextHopList:
    AssociationPropertyMetadata:
      Parameters:
        NextHopId:
          Required: true
          Type: String
          Description:
            en: Route entry next hop Instance id or Tunnel id.
          Label:
            en: NextHopId
        NextHopType:
          Default: RouterInterface
          Required: false
          Type: String
          Description:
            en: Route entry next hop type. Now support 'RouterInterface'.
          Label:
            en: NextHopType
    Description:
      en: The route entry's next hop list. If router is virtual border router, the value will be ignore. The list should contain 2-4 next hop. NextHopId of each next hop must be RouterInterface that VRouter forwards to VBR.
    Default: Null
    Required: false
    Label:
      en: NextHopList
    AssociationProperty: List[Parameters]
    Type: Json
Resources:
  RouteEntry:
    Type: ALIYUN::ECS::Route
    Properties:
      DestinationCidrBlock:
        Ref: DestinationCidrBlock
      RouteTableId:
        Ref: RouteTableId
      NextHopType:
        Ref: NextHopType
      NextHopId:
        Ref: NextHopId
      NextHopList:
        Ref: NextHopList
Outputs:
  RouteEntryId:
    Description: The ID of the route entry.
    Value:
      Fn::GetAtt:
        - RouteEntry
        - RouteEntryId
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "DestinationCidrBlock": {
      "Required": true,
      "Type": "String",
      "Description": {
        "en": "The RouteEntry's target network segment."
      },
      "Label": {
        "en": "DestinationCidrBlock"
      }
    },
    "RouteTableId": {
      "Required": true,
      "Type": "String",
      "Description": {
        "en": "RouteTableId of created route entry."
      },
      "Label": {
        "en": "RouteTableId"
      }
    },
    "NextHopType": {
      "Default": "Instance",
      "Required": false,
      "Type": "String",
      "Description": {
        "en": "The next hop type. Now support 'Instance|HaVip|RouterInterface|NetworkInterface|VpnGateway|IPv6Gateway|NatGateway|Attachment'. The default value is Instance.When the NextHopList is specified, the value will be ignored."
      },
      "Label": {
        "en": "NextHopType"
      }
    },
    "NextHopId": {
      "Default": null,
      "Required": false,
      "Type": "String",
      "Description": {
        "en": "The route entry's next hop. When the NextHopList is specified, the value will be ignored."
      },
      "Label": {
        "en": "NextHopId"
      }
    },
    "NextHopList": {
      "AssociationPropertyMetadata": {
        "Parameters": {
          "NextHopId": {
            "Required": true,
            "Type": "String",
            "Description": {
              "en": "Route entry next hop Instance id or Tunnel id."
            },
            "Label": {
              "en": "NextHopId"
            }
          },
          "NextHopType": {
            "Default": "RouterInterface",
            "Required": false,
            "Type": "String",
            "Description": {
              "en": "Route entry next hop type. Now support 'RouterInterface'."
            },
            "Label": {
              "en": "NextHopType"
            }
          }
        }
      },
      "Description": {
        "en": "The route entry's next hop list. If router is virtual border router, the value will be ignore. The list should contain 2-4 next hop. NextHopId of each next hop must be RouterInterface that VRouter forwards to VBR."
      },
      "Default": null,
      "Required": false,
      "Label": {
        "en": "NextHopList"
      },
      "AssociationProperty": "List[Parameters]",
      "Type": "Json"
    }
  },
  "Resources": {
    "RouteEntry": {
      "Type": "ALIYUN::ECS::Route",
      "Properties": {
        "DestinationCidrBlock": {
          "Ref": "DestinationCidrBlock"
        },
        "RouteTableId": {
          "Ref": "RouteTableId"
        },
        "NextHopType": {
          "Ref": "NextHopType"
        },
        "NextHopId": {
          "Ref": "NextHopId"
        },
        "NextHopList": {
          "Ref": "NextHopList"
        }
      }
    }
  },
  "Outputs": {
    "RouteEntryId": {
      "Description": "The ID of the route entry.",
      "Value": {
        "Fn::GetAtt": [
          "RouteEntry",
          "RouteEntryId"
        ]
      }
    }
  }
}

Cenário 3: Criar um cluster WordPress.

Criação rápida

ROSTemplateFormatVersion: '2015-09-01'
Description:
  en: Create a WordPress cluster, including VPC, ECS, SLB, and RDS resources. Automatically configure network and load balancing. Support customized instance specifications, quantity, and database configurations.
Parameters:
  VpcCidrBlock:
    Type: String
    Label:
      en: VPC Cidrblock
    Description:
      en: 'The IP address range of the VPC in the CIDR block form. You can use the
        following IP address ranges and their subnets: 10.0.0.0/8 172.16.0.0/12  192.168.0.0/16'
    Default: 10.0.0.0/8
    AllowedValues:
    - 192.168.0.0/16
    - 172.16.0.0/12
    - 10.0.0.0/8
  ZoneId:
    Type: String
    Label:
      en: Zone ID
    Description:
      en: The available zone ID. Confirm that the selected zone supports resources such as ECS, VPC, and VSwitch.
    AssociationProperty: ALIYUN::ECS::Instance::ZoneId
  VSwitchCidrBlock:
    Type: String
    Label:
      en: VSwitch CidrBlock
    Description:
      en: The vSwitch CIDR block. It must be a subnet of the VPC.
    Default: 10.0.10.0/24
  InstanceType:
    Type: String
    Label:
      en: Instance Type
    Description:
      en: "<font color='blue'>1. Before selecting the instance type, confirm that the current zone has the model in stock. Some models require prior approval.</font><font color='blue'><b>2. List of optional models:</font><br></font>[ecs.c5.large <font color='green'>2vCPU 4GiB internal bandwidth 1 Gbps internal network packet forwarding 300,000 PPS</font>][ecs.c5.xlarge <font color='green'>4vCPU 8GiB internal bandwidth 1.5 Gbps internal network packet forwarding 500,000 PPS</font>][ecs.c5.2xlarge <font color='green'>8vCPU 16GiB internal bandwidth 2.5 Gbps internal network packet forwarding 800,000 PPS</font>]"
    AssociationProperty: ALIYUN::ECS::Instance::InstanceType
    AssociationPropertyMetadata:
      ZoneId: ZoneId
  ImageId:
    Type: String
    Label:
      en: Image ID
    Description:
      en: 'Instance runtime image. For more information, see <a href=''https://www.alibabacloud.com/help/doc-detail/112977.html''
        target=''_blank''><font color=''blue''>Find the runtime image</font></a>'
    AssociationProperty: ALIYUN::ECS::Image::ImageId
    AssociationPropertyMetadata:
      InstanceType: ${InstanceType}
      SupportedImageOwnerAlias:
        - system
        - self
        - others
    Default: centos_7_04_64_20G_alibase_201701015.vhd
  InstancePassword:
    Type: String
    Label:
      en: Instance Password
    Description:
      en: The 8-30 long login password of instance, consists of the uppercase, lowercase
        letter and number.  special characters include()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
    ConstraintDescription:
      en: 'Length 8-30, must contain upper case letters, lower case letters, Numbers,
        special symbols three; special characters include the following: ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/'
    AllowedPattern: '[0-9A-Za-z\_\-&:;''<>,=%`~!@#\(\)\$\^\*\+\|\{\}\[\]\.\?\/]+$'
    MinLength: '8'
    MaxLength: '30'
    NoEcho: true
  NumberOfNode:
    Type: Number
    Label:
      en: Instances Amount
    Description:
      en: Number of WordPress servers.
    Default: 3
    MinValue: 1
    MaxValue: 100
  SystemDiskCategory:
    Type: String
    Label:
      en: System Disk Type
    Description:
      en: '<font color=''blue''><b>Optional 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 disk</font>]'
    AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
    AssociationPropertyMetadata:
      LocaleKey: DiskCategory
      InstanceType: ${InstanceType}
      ZoneId: ZoneId
  LoadBalancerSpec:
    Type: String
    Label:
      en: Specifications
    Description:
      en: Instance specifications.</br>For more information, see <b><a href='https://www.alibabacloud.com/help/doc-detail/85939.html'
        target='_blank'><b><font color='blue'>high-performance</font></a>
    Default: slb.s1.small
  Category:
    AssociationPropertyMetadata:
      LocaleKey: RDSCategory
    Default: Null
    Required: false
    AllowedValues:
      - Basic
      - HighAvailability
      - cluster
    Label:
      en: Category
    Type: String
  DBInstanceClass:
    Type: String
    Label:
      en: Instance Class
    Description:
      en: Database instance type. Refer the RDS database instance type.<a href='https://www.alibabacloud.com/help/doc-detail/26312.htm'
        target='_blank'>View RDS resources type</a>
    AssociationProperty: ALIYUN::RDS::Instance::InstanceType
    AssociationPropertyMetadata:
      Engine: MySQL
      Category: ${Category}
      EngineVersion: ${EngineVersion}
      ZoneId: ${ZoneId}
    Default: rds.mysql.s1.small
  EngineVersion:
    Type: String
    Label:
      en: Engine Version
    Description:
      en: RDS MySQL database engine version.
    AssociationProperty: ALIYUN::RDS::Engine::EngineVersion
    AssociationPropertyMetadata:
      Engine: MySQL
    Default: '8.0'
  DBInstanceStorage:
    Type: Number
    Label:
      en: Storage Size
    Description:
      en: 'Database storage size. Incrementing in every 5 GB.'
    ConstraintDescription:
      en: 'Incrementing in every 5 GB.'
    Default: 50
    MinValue: 5
    MaxValue: 2000
  DBName:
    Type: String
    Label:
      en: DB Name
    Description:
      en: Name of the WordPress database.
    ConstraintDescription:
      en: Consists of 2 to 64 lowercase letters and underscores. It must start with a letter and end with an alphanumeric character.
    Default: wordpress
    MinLength: 2
    MaxLength: 64
  DBUser:
    Type: String
    Label:
      en: DB Username
    Description:
      en: WordPress database account.
    ConstraintDescription:
      en: Consists of 2 to 64 lowercase letters and underscores. It must start with a letter and end with an alphanumeric character.
    Default: wpuser
    MinLength: 2
    MaxLength: 16
  DBPassword:
    Type: String
    Label:
      en: DB Password
    Description:
      en: The WordPress database password consists of 8 to 32 alphanumeric characters, hyphens, and underscores.
    ConstraintDescription:
      en: Consists of 8 to 32 alphanumeric characters, hyphens, and underscores.
    MinLength: 8
    MaxLength: 32
    NoEcho: true
Resources:
  LoadBalancer:
    Type: ALIYUN::SLB::LoadBalancer
    Properties:
      LoadBalancerName: wordpress_cluster_slb
      LoadBalancerSpec:
        Ref: LoadBalancerSpec
  AttachEcs:
    Type: ALIYUN::SLB::BackendServerAttachment
    Properties:
      BackendServers:
      - ServerId:
          Fn::Select:
          - '0'
          - Fn::GetAtt:
            - WebServerGroup
            - InstanceIds
        Weight: 100
      - ServerId:
          Fn::Select:
          - '1'
          - Fn::GetAtt:
            - WebServerGroup
            - InstanceIds
        Weight: 100
      - ServerId:
          Fn::Select:
          - '2'
          - Fn::GetAtt:
            - WebServerGroup
            - InstanceIds
        Weight: 100
      LoadBalancerId:
        Ref: LoadBalancer
  CreateListener_80:
    Type: ALIYUN::SLB::Listener
    Properties:
      BackendServerPort: '80'
      Bandwidth: 100
      HealthCheck:
        HealthyThreshold: 3
        HttpCode: http_2xx,http_3xx,http_4xx,http_5xx
        Interval: 2
        Timeout: 5
        UnhealthyThreshold: 3
      ListenerPort: '80'
      LoadBalancerId:
        Ref: LoadBalancer
      Protocol: http
      Scheduler: wrr
  Vpc:
    Type: ALIYUN::ECS::VPC
    Properties:
      CidrBlock:
        Ref: VpcCidrBlock
      VpcName: wordpress_cluster
  SecurityGroup:
    Type: ALIYUN::ECS::SecurityGroup
    Properties:
      VpcId:
        Ref: Vpc
      SecurityGroupEgress:
      - DestCidrIp: 0.0.0.0/0
        IpProtocol: all
        NicType: internet
        PortRange: -1/-1
        Priority: 1
      - DestCidrIp: 0.0.0.0/0
        IpProtocol: all
        NicType: intranet
        PortRange: -1/-1
        Priority: 1
      SecurityGroupIngress:
      - IpProtocol: tcp
        NicType: internet
        PortRange: 80/80
        Priority: 1
        SourceCidrIp: 0.0.0.0/0
      - IpProtocol: all
        NicType: intranet
        PortRange: -1/-1
        Priority: 1
        SourceCidrIp: 0.0.0.0/0
      SecurityGroupName: wordpress_cluster_sg
  VSwitch:
    Type: ALIYUN::ECS::VSwitch
    Properties:
      ZoneId:
        Ref: ZoneId
      VpcId:
        Ref: Vpc
      CidrBlock:
        Ref: VSwitchCidrBlock
  ECSSnatGateWay:
    Type: ALIYUN::ECS::Instance
    Properties:
      VpcId:
        Fn::GetAtt:
        - Vpc
        - VpcId
      VSwitchId:
        Ref: VSwitch
      SecurityGroupId:
        Fn::GetAtt:
        - SecurityGroup
        - SecurityGroupId
      ImageId:
        Ref: ImageId
      InstanceType:
        Ref: InstanceType
      InternetMaxBandwidthOut: 80
      Password:
        Ref: InstancePassword
      Tags:
      - Key: ECS_SNAT_GATEWAY
        Value: ecs_snat_gateway
      UserData:
        Fn::Replace:
        - ros-notify:
            Fn::GetAtt:
            - ECSSnatGateWayConditionHandle
            - CurlCli
        - Fn::Join:
          - ''
          - - '#!/bin/sh'
            - '

              '
            - PostRouting=
            - Ref: VSwitchCidrBlock
            - '

              '
            - SourceRouting=`ifconfig eth0|grep inet|awk '{print $2}'|tr -d 'addr:'`
            - '

              '
            - "echo 'net.ipv4.ip_forward=1'>> /etc/sysctl.conf \n"
            - "sysctl -p \n"
            - "iptables -t nat -I POSTROUTING -s $PostRouting -j SNAT --to-source\
              \ $SourceRouting \n"
            - 'apt-get update

              '
            - 'apt-get install -y curl

              '
            - 'ros-notify -d ''{"data" : "Docker swarm created"}''

              '
  ECSSnatGateWayConditionHandle:
    Type: ALIYUN::ROS::WaitConditionHandle
    Properties: {}
  ECSSnatGateWayGroupWaitCondition:
    Type: ALIYUN::ROS::WaitCondition
    Properties:
      Count: 1
      Handle:
        Ref: ECSSnatGateWayConditionHandle
      Timeout: 600
    DependsOn: ECSSnatGateWay
  Database:
    Type: ALIYUN::RDS::DBInstance
    Properties:
      VPCId:
        Ref: Vpc
      VSwitchId:
        Ref: VSwitch
      DBInstanceClass:
        Ref: DBInstanceClass
      DBInstanceDescription: DataBase
      DBInstanceStorage:
        Ref: DBInstanceStorage
      DBMappings:
      - CharacterSetName: utf8
        DBName:
          Ref: DBName
      Engine: MySQL
      Category:
        Ref: Category
      EngineVersion:
        Ref: EngineVersion
      MasterUserPassword:
        Ref: DBPassword
      MasterUsername:
        Ref: DBUser
      SecurityIPList: 0.0.0.0/0
    DependsOn: ECSSnatGateWayGroupWaitCondition
  VRoute:
    Type: ALIYUN::ECS::Route
    Properties:
      DestinationCidrBlock: 0.0.0.0/0
      NextHopId:
        Fn::GetAtt:
        - ECSSnatGateWay
        - InstanceId
      RouteId:
        Fn::GetAtt:
        - Vpc
        - VRouterId
      RouteTableId:
        Fn::GetAtt:
        - Vpc
        - RouteTableId
  WebServerGroup:
    Type: ALIYUN::ECS::InstanceGroup
    Properties:
      VpcId:
        Ref: Vpc
      VSwitchId:
        Ref: VSwitch
      SecurityGroupId:
        Ref: SecurityGroup
      ImageId:
        Ref: ImageId
      AllocatePublicIP: true
      InstanceType:
        Ref: InstanceType
      IoOptimized: optimized
      MaxAmount:
        Ref: NumberOfNode
      Password:
        Ref: InstancePassword
      SystemDiskCategory:
        Ref: SystemDiskCategory
      UserData:
        Fn::Replace:
        - ros-notify:
            Fn::GetAtt:
            - WebServerGroupConditionHandle
            - CurlCli
        - Fn::Join:
          - ''
          - - '#!/bin/sh'
            - '

              '
            - DatabaseUser=
            - Ref: DBUser
            - '

              '
            - DatabasePwd=
            - Ref: DBPassword
            - '

              '
            - DatabaseName=
            - Ref: DBName
            - '

              '
            - DatabaseHost=
            - Fn::GetAtt:
              - Database
              - InnerConnectionString
            - '

              '
            - 'WebRootPath=''/var/www/html''

              '
            - 'ApacheIndex=''Options Indexes FollowSymLinks''

              '
            - 'ApacheIndexReplace=''Options FollowSymLinks''

              '
            - 'mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

              '
            - 'wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

              '
            - 'yum makecache

              '
            - "yum install -y unzip zip \n"
            - "yum install -y curl httpd mysql-server php56 php56-php-mysql \n"
            - "rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm \n"
            - "rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm \n"
            - "yum install -y php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64\
              \ php56w-gd.x86_64 php56w-imap.x86_64 php56w-ldap.x86_64 php56w-mysql.x86_64\
              \ php56w-pdo.x86_64 php56w-odbc.x86_64 php56w-process.x86_64 php56w-xml.x86_64\
              \ php56w-xmlrpc.x86_64 \n"
            - 'chkconfig httpd on

              '
            - '#wget http://wordpress.org/latest.tar.gz

              '
            - '#tar -xzvf latest.tar.gz

              '
            - "wget https://ros-template-resources.oss-cn-beijing.aliyuncs.com/WordPress/WordPress.zip \n"
            - "unzip WordPress.zip \n"
            - "mv WordPress-master wordpress \n"
            - 'sed -i "s/database_name_here/$DatabaseName/" wordpress/wp-config-sample.php

              '
            - 'sed -i "s/username_here/$DatabaseUser/" wordpress/wp-config-sample.php

              '
            - 'sed -i "s/password_here/${DatabasePwd:-$DatabasePwdDef}/" wordpress/wp-config-sample.php

              '
            - 'sed -i "s/localhost/$DatabaseHost/" wordpress/wp-config-sample.php

              '
            - 'mv wordpress/wp-config-sample.php wordpress/wp-config.php

              '
            - 'cp -a wordpress/* $WebRootPath

              '
            - 'rm -rf wordpress*

              '
            - 'service httpd stop

              '
            - 'usermod -d $WebRootPath apache &>/dev/null

              '
            - 'chown apache:apache -R $WebRootPath

              '
            - 'sed -i "s/$ApacheIndex/$ApacheIndexReplace/" /etc/httpd/conf/httpd.conf

              '
            - 'service httpd start

              '
            - 'ros-notify -d ''{"data" : "Install WordPress"}''

              '
    DependsOn: Database
  WebServerGroupConditionHandle:
    Type: ALIYUN::ROS::WaitConditionHandle
    Properties: {}
  WebServerGroupWaitCondition:
    Type: ALIYUN::ROS::WaitCondition
    Properties:
      Count:
        Ref: NumberOfNode
      Handle:
        Ref: WebServerGroupConditionHandle
      Timeout: 900
    DependsOn: WebServerGroup
Outputs:
  JumpHostIp:
    Description:
      en: The jump host IP.
    Value:
      Fn::GetAtt:
      - ECSSnatGateWay
      - PublicIp
  WordPressUrl:
    Description:
      en: WordPress URL.
    Value:
      Fn::Join:
      - ''
      - - http://
        - Fn::GetAtt:
          - LoadBalancer
          - IpAddress
        - :80
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
    - Parameters:
      - VpcCidrBlock
      - ZoneId
      - VSwitchCidrBlock
      Label:
        default:
          en: VPC
    - Parameters:
      - InstanceType
      - ImageId
      - SystemDiskCategory
      - NumberOfNode
      - InstancePassword
      Label:
        default:
          en: ECS
    - Parameters:
      - LoadBalancerSpec
      Label:
        default:
          en: SLB
    - Parameters:
      - Category
      - EngineVersion
      - DBInstanceClass
      - DBInstanceStorage
      - DBName
      - DBUser
      - DBPassword
      Label:
        default:
          en: RDS
    TemplateTags:
    - acs:example:Network:Create a WordPress cluster and configure VPC SNAT to access the Internet
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "en": "Create a WordPress cluster, including VPC, ECS, SLB, and RDS resources. Automatically configure network and load balancing. Support customized instance specifications, quantity, and database configurations."
  },
  "Parameters": {
    "VpcCidrBlock": {
      "Type": "String",
      "Label": {
        "en": "VPC Cidrblock"
      },
      "Description": {
        "en": "The IP address range of the VPC in the CIDR block form. You can use the following IP address ranges and their subnets: 10.0.0.0/8 172.16.0.0/12  192.168.0.0/16"
      },
      "Default": "10.0.0.0/8",
      "AllowedValues": [
        "192.168.0.0/16",
        "172.16.0.0/12",
        "10.0.0.0/8"
      ]
    },
    "ZoneId": {
      "Type": "String",
      "Label": {
        "en": "Zone ID"
      },
      "Description": {
        "en": "The available zone ID. Confirm that the selected zone supports resources such as ECS, VPC, and VSwitch."
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::ZoneId"
    },
    "VSwitchCidrBlock": {
      "Type": "String",
      "Label": {
        "en": "VSwitch CidrBlock"
      },
      "Description": {
        "en": "The vSwitch CIDR block. It must be a subnet of the VPC."
      },
      "Default": "10.0.10.0/24"
    },
    "InstanceType": {
      "Type": "String",
      "Label": {
        "en": "Instance Type"
      },
      "Description": {
        "en": "<font color='blue'>1. Before selecting the instance type, confirm that the current zone has the model in stock. Some models require prior approval.</font><font color='blue'><b>2. List of optional models:</font><br></font>[ecs.c5.large <font color='green'>2vCPU 4GiB internal bandwidth 1 Gbps internal network packet forwarding 300,000 PPS</font>][ecs.c5.xlarge <font color='green'>4vCPU 8GiB internal bandwidth 1.5 Gbps internal network packet forwarding 500,000 PPS</font>][ecs.c5.2xlarge <font color='green'>8vCPU 16GiB internal bandwidth 2.5 Gbps internal network packet forwarding 800,000 PPS</font>]"
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "ZoneId": "ZoneId"
      }
    },
    "ImageId": {
      "Type": "String",
      "Label": {
        "en": "Image ID"
      },
      "Description": {
        "en": "Instance runtime image. For more information, see <a href='https://www.alibabacloud.com/help/doc-detail/112977.html' target='_blank'><font color='blue'>Find the runtime image</font></a>"
      },
      "AssociationProperty": "ALIYUN::ECS::Image::ImageId",
      "AssociationPropertyMetadata": {
        "InstanceType": "${InstanceType}",
        "SupportedImageOwnerAlias": [
          "system",
          "self",
          "others"
        ]
      },
      "Default": "centos_7_04_64_20G_alibase_201701015.vhd"
    },
    "InstancePassword": {
      "Type": "String",
      "Label": {
        "en": "Instance Password"
      },
      "Description": {
        "en": "The 8-30 long login password of instance, consists of the uppercase, lowercase
        letter and number.  special characters include()`~!@#$%^&*_-+=|{}[]:;'<>,.?/"
      },
      "ConstraintDescription": {
        "en": "Length 8-30, must contain upper case letters, lower case letters, Numbers,
        special symbols three; special characters include the following: ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/"
      },
      "AllowedPattern": "[0-9A-Za-z\\_\\-&:;'<>,=%`~!@#\\(\\)\\$\\^\\*\\+\\|\\{\\}\\[\\]\\.\\?\\/]+$",
      "MinLength": "8",
      "MaxLength": "30",
      "NoEcho": true
    },
    "NumberOfNode": {
      "Type": "Number",
      "Label": {
        "en": "Instances Amount"
      },
      "Description": {
        "en": "Number of WordPress servers."
      },
      "Default": 3,
      "MinValue": 1,
      "MaxValue": 100
    },
    "SystemDiskCategory": {
      "Type": "String",
      "Label": {
        "en": "System Disk Type"
      },
      "Description": {
        "en": "<font color='blue'><b>Optional 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 disk</font>]"
      },
      "AssociationProperty": "ALIYUN::ECS::Disk::SystemDiskCategory",
      "AssociationPropertyMetadata": {
        "LocaleKey": "DiskCategory",
        "InstanceType": "${InstanceType}",
        "ZoneId": "ZoneId"
      }
    },
    "LoadBalancerSpec": {
      "Type": "String",
      "Label": {
        "en": "Specifications"
      },
      "Description": {
        "en": "Instance specifications.</br>For more information, see <b><a href='https://www.alibabacloud.com/help/doc-detail/85939.html' target='_blank'><b><font color='blue'>high-performance</font></a>"
      },
      "Default": "slb.s1.small"
    },
    "Category": {
      "AssociationPropertyMetadata": {
        "LocaleKey": "RDSCategory"
      },
      "Default": null,
      "Required": false,
      "AllowedValues": [
        "Basic",
        "HighAvailability",
        "cluster"
      ],
      "Label": {
        "en": "Category"
      },
      "Type": "String"
    },
    "DBInstanceClass": {
      "Type": "String",
      "Label": {
        "en": "Instance Class"
      },
      "Description": {
        "en": "Database instance type. Refer the RDS database instance type.<a href='https://www.alibabacloud.com/help/doc-detail/26312.htm' target='_blank'>View RDS resources type</a>"
      },
      "AssociationProperty": "ALIYUN::RDS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "Engine": "MySQL",
        "Category": "${Category}",
        "EngineVersion": "${EngineVersion}",
        "ZoneId": "${ZoneId}"
      },
      "Default": "rds.mysql.s1.small"
    },
    "EngineVersion": {
      "Type": "String",
      "Label": {
        "en": "Engine Version"
      },
      "Description": {
        "en": "RDS MySQL database engine version."
      },
      "AssociationProperty": "ALIYUN::RDS::Engine::EngineVersion",
      "AssociationPropertyMetadata": {
        "Engine": "MySQL"
      },
      "Default": "8.0"
    },
    "DBInstanceStorage": {
      "Type": "Number",
      "Label": {
        "en": "Storage Size"
      },
      "Description": {
        "en": "Database storage size. Incrementing in every 5 GB."
      },
      "ConstraintDescription": {
        "en": "Incrementing in every 5 GB."
      },
      "Default": 50,
      "MinValue": 5,
      "MaxValue": 2000
    },
    "DBName": {
      "Type": "String",
      "Label": {
        "en": "DB Name"
      },
      "Description": {
        "en": "Name of the WordPress database."
      },
      "ConstraintDescription": {
        "en": "Consists of 2 to 64 lowercase letters and underscores. It must start with a letter and end with an alphanumeric character."
      },
      "Default": "wordpress",
      "MinLength": 2,
      "MaxLength": 64
    },
    "DBUser": {
      "Type": "String",
      "Label": {
        "en": "DB Username"
      },
      "Description": {
        "en": "WordPress database account."
      },
      "ConstraintDescription": {
        "en": "Consists of 2 to 64 lowercase letters and underscores. It must start with a letter and end with an alphanumeric character."
      },
      "Default": "wpuser",
      "MinLength": 2,
      "MaxLength": 16
    },
    "DBPassword": {
      "Type": "String",
      "Label": {
        "en": "DB Password"
      },
      "Description": {
        "en": "The WordPress database password consists of 8 to 32 alphanumeric characters, hyphens, and underscores."
      },
      "ConstraintDescription": {
        "en": "Consists of 8 to 32 alphanumeric characters, hyphens, and underscores."
      },
      "MinLength": 8,
      "MaxLength": 32,
      "NoEcho": true
    }
  },
  "Resources": {
    "LoadBalancer": {
      "Type": "ALIYUN::SLB::LoadBalancer",
      "Properties": {
        "LoadBalancerName": "wordpress_cluster_slb",
        "LoadBalancerSpec": {
          "Ref": "LoadBalancerSpec"
        }
      }
    },
    "AttachEcs": {
      "Type": "ALIYUN::SLB::BackendServerAttachment",
      "Properties": {
        "BackendServers": [
          {
            "ServerId": {
              "Fn::Select": [
                "0",
                {
                  "Fn::GetAtt": [
                    "WebServerGroup",
                    "InstanceIds"
                  ]
                }
              ]
            },
            "Weight": 100
          },
          {
            "ServerId": {
              "Fn::Select": [
                "1",
                {
                  "Fn::GetAtt": [
                    "WebServerGroup",
                    "InstanceIds"
                  ]
                }
              ]
            },
            "Weight": 100
          },
          {
            "ServerId": {
              "Fn::Select": [
                "2",
                {
                  "Fn::GetAtt": [
                    "WebServerGroup",
                    "InstanceIds"
                  ]
                }
              ]
            },
            "Weight": 100
          }
        ],
        "LoadBalancerId": {
          "Ref": "LoadBalancer"
        }
      }
    },
    "CreateListener_80": {
      "Type": "ALIYUN::SLB::Listener",
      "Properties": {
        "BackendServerPort": "80",
        "Bandwidth": 100,
        "HealthCheck": {
          "HealthyThreshold": 3,
          "HttpCode": "http_2xx,http_3xx,http_4xx,http_5xx",
          "Interval": 2,
          "Timeout": 5,
          "UnhealthyThreshold": 3
        },
        "ListenerPort": "80",
        "LoadBalancerId": {
          "Ref": "LoadBalancer"
        },
        "Protocol": "http",
        "Scheduler": "wrr"
      }
    },
    "Vpc": {
      "Type": "ALIYUN::ECS::VPC",
      "Properties": {
        "CidrBlock": {
          "Ref": "VpcCidrBlock"
        },
        "VpcName": "wordpress_cluster"
      }
    },
    "SecurityGroup": {
      "Type": "ALIYUN::ECS::SecurityGroup",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "SecurityGroupEgress": [
          {
            "DestCidrIp": "0.0.0.0/0",
            "IpProtocol": "all",
            "NicType": "internet",
            "PortRange": "-1/-1",
            "Priority": 1
          },
          {
            "DestCidrIp": "0.0.0.0/0",
            "IpProtocol": "all",
            "NicType": "intranet",
            "PortRange": "-1/-1",
            "Priority": 1
          }
        ],
        "SecurityGroupIngress": [
          {
            "IpProtocol": "tcp",
            "NicType": "internet",
            "PortRange": "80/80",
            "Priority": 1,
            "SourceCidrIp": "0.0.0.0/0"
          },
          {
            "IpProtocol": "all",
            "NicType": "intranet",
            "PortRange": "-1/-1",
            "Priority": 1,
            "SourceCidrIp": "0.0.0.0/0"
          }
        ],
        "SecurityGroupName": "wordpress_cluster_sg"
      }
    },
    "VSwitch": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "ZoneId": {
          "Ref": "ZoneId"
        },
        "VpcId": {
          "Ref": "Vpc"
        },
        "CidrBlock": {
          "Ref": "VSwitchCidrBlock"
        }
      }
    },
    "ECSSnatGateWay": {
      "Type": "ALIYUN::ECS::Instance",
      "Properties": {
        "VpcId": {
          "Fn::GetAtt": [
            "Vpc",
            "VpcId"
          ]
        },
        "VSwitchId": {
          "Ref": "VSwitch"
        },
        "SecurityGroupId": {
          "Fn::GetAtt": [
            "SecurityGroup",
            "SecurityGroupId"
          ]
        },
        "ImageId": {
          "Ref": "ImageId"
        },
        "InstanceType": {
          "Ref": "InstanceType"
        },
        "InternetMaxBandwidthOut": 80,
        "Password": {
          "Ref": "InstancePassword"
        },
        "Tags": [
          {
            "Key": "ECS_SNAT_GATEWAY",
            "Value": "ecs_snat_gateway"
          }
        ],
        "UserData": {
          "Fn::Replace": [
            {
              "ros-notify": {
                "Fn::GetAtt": [
                  "ECSSnatGateWayConditionHandle",
                  "CurlCli"
                ]
              }
            },
            {
              "Fn::Join": [
                "",
                [
                  "#!/bin/sh",
                  "\n",
                  "PostRouting=",
                  {
                    "Ref": "VSwitchCidrBlock"
                  },
                  "\n",
                  "SourceRouting=`ifconfig eth0|grep inet|awk '{print $2}'|tr -d 'addr:'`",
                  "\n",
                  "echo 'net.ipv4.ip_forward=1'>> /etc/sysctl.conf \n",
                  "sysctl -p \n",
                  "iptables -t nat -I POSTROUTING -s $PostRouting -j SNAT --to-source $SourceRouting \n",
                  "apt-get update\n",
                  "apt-get install -y curl\n",
                  "ros-notify -d '{\"data\" : \"Docker swarm created\"}'\n"
                ]
              ]
            }
          ]
        }
      }
    },
    "ECSSnatGateWayConditionHandle": {
      "Type": "ALIYUN::ROS::WaitConditionHandle",
      "Properties": {}
    },
    "ECSSnatGateWayGroupWaitCondition": {
      "Type": "ALIYUN::ROS::WaitCondition",
      "Properties": {
        "Count": 1,
        "Handle": {
          "Ref": "ECSSnatGateWayConditionHandle"
        },
        "Timeout": 600
      },
      "DependsOn": "ECSSnatGateWay"
    },
    "Database": {
      "Type": "ALIYUN::RDS::DBInstance",
      "Properties": {
        "VPCId": {
          "Ref": "Vpc"
        },
        "VSwitchId": {
          "Ref": "VSwitch"
        },
        "DBInstanceClass": {
          "Ref": "DBInstanceClass"
        },
        "DBInstanceDescription": "DataBase",
        "DBInstanceStorage": {
          "Ref": "DBInstanceStorage"
        },
        "DBMappings": [
          {
            "CharacterSetName": "utf8",
            "DBName": {
              "Ref": "DBName"
            }
          }
        ],
        "Engine": "MySQL",
        "Category": {
          "Ref": "Category"
        },
        "EngineVersion": {
          "Ref": "EngineVersion"
        },
        "MasterUserPassword": {
          "Ref": "DBPassword"
        },
        "MasterUsername": {
          "Ref": "DBUser"
        },
        "SecurityIPList": "0.0.0.0/0"
      },
      "DependsOn": "ECSSnatGateWayGroupWaitCondition"
    },
    "VRoute": {
      "Type": "ALIYUN::ECS::Route",
      "Properties": {
        "DestinationCidrBlock": "0.0.0.0/0",
        "NextHopId": {
          "Fn::GetAtt": [
            "ECSSnatGateWay",
            "InstanceId"
          ]
        },
        "RouteId": {
          "Fn::GetAtt": [
            "Vpc",
            "VRouterId"
          ]
        },
        "RouteTableId": {
          "Fn::GetAtt": [
            "Vpc",
            "RouteTableId"
          ]
        }
      }
    },
    "WebServerGroup": {
      "Type": "ALIYUN::ECS::InstanceGroup",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "VSwitchId": {
          "Ref": "VSwitch"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroup"
        },
        "ImageId": {
          "Ref": "ImageId"
        },
        "AllocatePublicIP": true,
        "InstanceType": {
          "Ref": "InstanceType"
        },
        "IoOptimized": "optimized",
        "MaxAmount": {
          "Ref": "NumberOfNode"
        },
        "Password": {
          "Ref": "InstancePassword"
        },
        "SystemDiskCategory": {
          "Ref": "SystemDiskCategory"
        },
        "UserData": {
          "Fn::Replace": [
            {
              "ros-notify": {
                "Fn::GetAtt": [
                  "WebServerGroupConditionHandle",
                  "CurlCli"
                ]
              }
            },
            {
              "Fn::Join": [
                "",
                [
                  "#!/bin/sh",
                  "\n",
                  "DatabaseUser=",
                  {
                    "Ref": "DBUser"
                  },
                  "\n",
                  "DatabasePwd=",
                  {
                    "Ref": "DBPassword"
                  },
                  "\n",
                  "DatabaseName=",
                  {
                    "Ref": "DBName"
                  },
                  "\n",
                  "DatabaseHost=",
                  {
                    "Fn::GetAtt": [
                      "Database",
                      "InnerConnectionString"
                    ]
                  },
                  "\n",
                  "WebRootPath='/var/www/html'\n",
                  "ApacheIndex='Options Indexes FollowSymLinks'\n",
                  "ApacheIndexReplace='Options FollowSymLinks'\n",
                  "mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup\n",
                  "wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo\n",
                  "yum makecache\n",
                  "yum install -y unzip zip \n",
                  "yum install -y curl httpd mysql-server php56 php56-php-mysql \n",
                  "rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm \n",
                  "rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm \n",
                  "yum install -y php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-imap.x86_64 php56w-ldap.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64 php56w-odbc.x86_64 php56w-process.x86_64 php56w-xml.x86_64 php56w-xmlrpc.x86_64 \n",
                  "chkconfig httpd on\n",
                  "#wget http://wordpress.org/latest.tar.gz\n",
                  "#tar -xzvf latest.tar.gz\n",
                  "wget https://ros-template-resources.oss-cn-beijing.aliyuncs.com/WordPress/WordPress.zip \n",
                  "unzip WordPress.zip \n",
                  "mv WordPress-master wordpress \n",
                  "sed -i \"s/database_name_here/$DatabaseName/\" wordpress/wp-config-sample.php\n",
                  "sed -i \"s/username_here/$DatabaseUser/\" wordpress/wp-config-sample.php\n",
                  "sed -i \"s/password_here/${DatabasePwd:-$DatabasePwdDef}/\" wordpress/wp-config-sample.php\n",
                  "sed -i \"s/localhost/$DatabaseHost/\" wordpress/wp-config-sample.php\n",
                  "mv wordpress/wp-config-sample.php wordpress/wp-config.php\n",
                  "cp -a wordpress/* $WebRootPath\n",
                  "rm -rf wordpress*\n",
                  "service httpd stop\n",
                  "usermod -d $WebRootPath apache &>/dev/null\n",
                  "chown apache:apache -R $WebRootPath\n",
                  "sed -i \"s/$ApacheIndex/$ApacheIndexReplace/\" /etc/httpd/conf/httpd.conf\n",
                  "service httpd start\n",
                  "ros-notify -d '{\"data\" : \"Install WordPress\"}'\n"
                ]
              ]
            }
          ]
        }
      },
      "DependsOn": "Database"
    },
    "WebServerGroupConditionHandle": {
      "Type": "ALIYUN::ROS::WaitConditionHandle",
      "Properties": {}
    },
    "WebServerGroupWaitCondition": {
      "Type": "ALIYUN::ROS::WaitCondition",
      "Properties": {
        "Count": {
          "Ref": "NumberOfNode"
        },
        "Handle": {
          "Ref": "WebServerGroupConditionHandle"
        },
        "Timeout": 900
      },
      "DependsOn": "WebServerGroup"
    }
  },
  "Outputs": {
    "JumpHostIp": {
      "Description": {
        "en": "The jump host IP."
      },
      "Value": {
        "Fn::GetAtt": [
          "ECSSnatGateWay",
          "PublicIp"
        ]
      }
    },
    "WordPressUrl": {
      "Description": {
        "en": "WordPress URL."
      },
      "Value": {
        "Fn::Join": [
          "",
          [
            "http://",
            {
              "Fn::GetAtt": [
                "LoadBalancer",
                "IpAddress"
              ]
            },
            ":80"
          ]
        ]
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "VpcCidrBlock",
            "ZoneId",
            "VSwitchCidrBlock"
          ],
          "Label": {
            "default": {
              "en": "VPC"
            }
          }
        },
        {
          "Parameters": [
            "InstanceType",
            "ImageId",
            "SystemDiskCategory",
            "NumberOfNode",
            "InstancePassword"
          ],
          "Label": {
            "default": {
              "en": "ECS"
            }
          }
        },
        {
          "Parameters": [
            "LoadBalancerSpec"
          ],
          "Label": {
            "default": {
              "en": "SLB"
            }
          }
        },
        {
          "Parameters": [
            "Category",
            "EngineVersion",
            "DBInstanceClass",
            "DBInstanceStorage",
            "DBName",
            "DBUser",
            "DBPassword"
          ],
          "Label": {
            "default": {
              "en": "RDS"
            }
          }
        }
      ],
      "TemplateTags": [
        "acs:example:Network:Create a WordPress cluster and configure VPC SNAT to access the Internet"
      ]
    }
  }
}

Para mais exemplos, consulte modelos públicos que incluem este recurso.