All Products
Search
Document Center

Resource Orchestration Service:Get started with template content

Last Updated:Jun 17, 2026

A template is a blueprint that defines cloud service resources and their dependencies for deployment through Resource Orchestration Service (ROS). This example walks you through writing a template that creates a virtual private cloud (VPC) and a vSwitch.

Prerequisites

You are familiar with the requirements on template structures. For more information, see Template structure.

Select a template editor

You can use an online or on-premises template editor. Both support automatic syntax hinting and resource property validation.

Define a template

To define a template, declare the resources you want to create in the Resources section. See Resource type index for all supported resource types. The documentation for each resource type lists supported properties and return values, including whether a property is required or editable. Required properties must be declared in the Properties part of the Resources section. Editable properties can be modified via a stack update; non-editable properties cannot be changed after creation.

  1. View details of the desired resource types.

    1. Refer to Resource type index to find the resource types that are suitable for your deployment scenario. In this example, the ALIYUN::ECS::VPC and ALIYUN::ECS::VSwitch resource types that are used to create a VPC and a vSwitch are suitable.

    2. Refer to the documentation of each resource type and view the resource properties.

  2. In the Parameters section, define the parameters of the template.

    Define VpcCidrBlock for the VPC, and ZoneId, VSwitchName, and VSwitchCidrBlock for the vSwitch. Parameters in this section appear as GUI elements in the ROS console. For more information, see ALIYUN::ECS::VPC and ALIYUN::ECS::VSwitch. The vSwitch CIDR block must fall within the VPC CIDR block.

    Parameters:
      VpcCidrBlock:
        Type: String
        Default: 192.168.0.0/16
        AllowedValues:
          - 10.0.0.0/8
          - 172.16.0.0/12
          - 192.168.0.0/16
      ZoneId:
        Type: String
        AssociationProperty: ALIYUN::ECS::Instance::ZoneId
      VSwitchName:
        Type: String
      VSwitchCidrBlock:
        Type: String
        Default: 192.168.0.0/24
        AllowedValues:
          - 10.0.0.0/24
          - 172.16.0.0/24
          - 192.168.0.0/24
  3. In the Resources section, define the resources that you want to create.

    VpcId, ZoneId, and CidrBlock are required for the vSwitch. Other properties are optional. For more information, see ALIYUN::ECS::VPC and ALIYUN::ECS::VSwitch. Use the Ref function to reference parameters, or specify values directly. For more information, see Ref.

    Resources:
      Vpc:
        Type: ALIYUN::ECS::VPC
        Properties:
          VpcName: MyTest
          CidrBlock:
            Ref: VpcCidrBlock 
      VSwitch:
        Type: ALIYUN::ECS::VSwitch
        Properties:
          VpcId:
            Ref: Vpc
          ZoneId:
            Ref: ZoneId
          VSwitchName:
            Ref: VSwitchName
          CidrBlock:
            Ref: VSwitchCidrBlock
  4. In the Outputs section, define the outputs of the template.

    Define VpcId and VSwitchId as outputs. For more information, see ALIYUN::ECS::VPC and ALIYUN::ECS::VSwitch. Use the Fn::GetAtt function to retrieve resource property values. For more information, see Fn::GetAtt.

    Outputs:
      VpcId:
        Value:
          Fn::GetAtt:
            - Vpc
            - VpcId
      VSwitchId:
        Value:
          Fn::GetAtt:
            - VSwitch
            - VSwitchId
  5. Follow the template structure to define the complete template content.

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      VSwitchName:
        Type: String
      VSwitchCidrBlock:
        Default: 192.168.0.0/24
        Type: String
        AllowedValues:
          - 10.0.0.0/24
          - 172.16.0.0/24
          - 192.168.0.0/24
      VpcCidrBlock:
        Default: 192.168.0.0/16
        Type: String
        AllowedValues:
          - 10.0.0.0/8
          - 172.16.0.0/12
          - 192.168.0.0/16
      ZoneId:
        AssociationProperty: ALIYUN::ECS::Instance::ZoneId
        Type: String
    Resources:
      VSwitch:
        Type: ALIYUN::ECS::VSwitch
        Properties:
          VSwitchName:
            Ref: VSwitchName
          VpcId:
            Ref: Vpc
          CidrBlock:
            Ref: VSwitchCidrBlock
          ZoneId:
            Ref: ZoneId
      Vpc:
        Type: ALIYUN::ECS::VPC
        Properties:
          VpcName: MyTest
          CidrBlock:
            Ref: VpcCidrBlock
    Outputs:
      VpcId:
        Value:
          Fn::GetAtt:
            - Vpc
            - VpcId
      VSwitchId:
        Value:
          Fn::GetAtt:
            - VSwitch
            - VSwitchId

What to do next

Use the defined template to create a stack or save the template as your private template. For more information, see Stack quick start and Create a template.

References