Resource Orchestration Service (ROS) is an Alibaba Cloud service that you can use to simplify the management of cloud computing resources. The first time you use ROS, you must compile a template to describe the cloud resources that you need and the dependencies between the resources. Then, you can use the template to create a stack to deploy the resources. This topic helps you get started with ROS and provides an example on how to compile a template that describes a virtual private cloud (VPC) and a vSwitch.

Prerequisites

An Alibaba Cloud account is created. To create an Alibaba Cloud account, see Create an Alibaba Cloud account.

Step 1: Compile a template

A template is a JSON, YAML, or Terraform file that is encoded in UTF-8. You must describe the Alibaba Cloud resources that you require, resource configurations, and resource dependencies in a template before you can use the template to create a stack. You can customize a template that follows the required template structure and includes the resource types that you need. You can also use a sample template.

For information about template structures, see JSON and YAML template structures and Terraform template structure.

The following example shows how to compile a template that describes a VPC and a vSwitch:

{
   "ROSTemplateFormatVersion": "2015-09-01",
   "Description": "Example of provisioning VPC and vSwitch.",
   "Parameters": {
     "VpcName": {
       "Type": "String",
       "Description": {
            
         "en": "The name must be 2 to 128 characters in length and can contain letters, digits, underscores (_), and hyphens (-). It must start with a letter and cannot start with http:// or  https://."
       },
       "Default": null
     },
     "VpcCidrBlock": {
       "Type": "String",
       "Description": {
          
         "en": "The CIDR block of the VPC."
       },
       "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",
       "Description": {
          
         "en": "Zone ID."
       },
       "AssociationProperty": "ALIYUN::ECS::Instance::ZoneId"
     },
     "VSwitchName": {
       "Type": "String",
       "Description": {
            
         "en": "The name must be 2 to 128 characters in length and can contain letters, digits, underscores (_), and hyphens (-). It must start with a letter and cannot start with http:// or  https://."
       },
       "Default": null
     },
     "VSwitchCidrBlock": {
       "Type": "String",
       "Description": {
          
         "en": "The CIDR block of the vSwitch."
       },
       "Default": "192.168.0.0/24",
       "AllowedValues": [
         "10.0.0.0/24",
         "172.16.0.0/24",
         "192.168.0.0/24"
       ]
     },
     "Tags": {
       "Type": "Json",
       "Description": {
           
         "en": "A maximum of 20 tags can be specified. Each tag is a key-value pair. The tag value can be left empty."
       },
       "Default": [
         {
           "Key": "ros",
           "Value": "beginner-tutorial"
         }
       ]
     }
   },
   "Resources": {
     "Vpc": {
       "Type": "ALIYUN::ECS::VPC",
       "Properties": {
         "VpcName": {
           "Ref": "VpcName"
         },
         "CidrBlock": {
           "Ref": "VpcCidrBlock"
         },
         "Tags": {
           "Ref": "Tags"
         }
       }
     },
     "VSwitch": {
       "Type": "ALIYUN::ECS::VSwitch",
       "Properties": {
         "VpcId": {
           "Ref": "Vpc"
         },
         "ZoneId": {"Ref": "ZoneId"},
         "VSwitchName": {
           "Ref": "VSwitchName"
         },
         "CidrBlock": {
           "Ref": "VSwitchCidrBlock"
         },
         "Tags": {
           "Ref": "Tags"
         }
       }
     }
   },
   "Outputs": {
     "VpcId": {
       "Description": "The VPC ID allocated by the system.",
       "Value": {
         "Fn::GetAtt": ["Vpc", "VpcId"]
       }
     },
     "VSwitchId": {
       "Description": "The vSwitch ID allocated by the system.",
       "Value": {
         "Fn::GetAtt": ["VSwitch", "VSwitchId"]
       }
     }
   }
 }

The following list describes the fields in the template:

  • ROSTemplateFormatVersion: the version number of the template. In this example, the version number is 2015-09-01.
  • Description: the description of the template, which includes information such as the scenarios and architecture of the template. We recommend that you enter a detailed description to help users understand how to use the template.
  • Parameters: the parameters in the template. In this example, the following parameters are included: VpcName, VpcCidrBlock, ZoneId, VSwitchName, VSwitchCidrBlock, and Tags. For more information about parameter meanings, see Overview.
  • Resources: the Alibaba Cloud resources included in the template. In this example, the resources are a VPC and a vSwitch. The parameters defined in Parameters are used as the properties of Resources. For more information about resources, see ALIYUN::ECS::VPC and ALIYUN::ECS::VSwitch.
  • Outputs: the resource information that is generated after the stack is created. In this example, the outputs are the VPC ID and vSwitch ID.

Step 2: Create a stack

If you want to quickly create a stack, you can use the template that is compiled in Step 1: Compile a template.

  1. Log on to the ROS console.
  2. In the left-side navigation pane, click Stacks.
  3. In the upper-left corner of the page, select a region in which you want to create a stack from the drop-down list. In this example, China (Hangzhou) is selected.
  4. On the Stacks page, click Create Stack and select Use New Resources (Standard) from the drop-down list.
  5. In the Select Template step, select Select an Existing Template in the Specify Template section and set Template Import Method to Enter Template Content. In the Template Content section, enter the content of the JSON template that you compiled in Step 1: Compile a template. Click Next.
  6. In the Configure Template Parameters step, configure Stack Name and the following parameters.
    Parameter Description Example
    VpcName The name of the VPC. myVPC
    VpcCidrBlock The CIDR block of the VPC. Default value: 192.168.0.0/16. Valid values:
    • 10.0.0.0/8
    • 172.16.0.0/12
    • 192.168.0.0/16
    192.168.0.0/16
    ZoneId The ID of the zone. Hangzhou Zone K
    VSwitchName The name of the vSwitch. myVSwitch
    VSwitchCidrBlock The CIDR block of the vSwitch. Valid values:
    • 10.0.0.0/24
    • 172.16.0.0/24
    • 192.168.0.0/24
    Note The vSwitch and the VPC must share the same CIDR block.
    192.168.0.0/24
    Tags The tags.

    A maximum of 20 tags can be specified. Each tag is a key-value pair. You can leave the tag value empty.

    [{"Key": "ros", "Value": "beginner-tutorial"}]
  7. Click Create.

Step 3: Use the resources in the stack

After the stack is created, you can use the resources in the stack based on your business requirements. For example, you can deploy Alibaba Cloud resources in a vSwitch of a VPC.

  1. Log on to the ROS console. In the left-side navigation pane, click Stacks.
  2. On the Stacks page, click the ID of the stack whose resources you want to use.
  3. Click the Resources tab and the ID of the vSwitch.
  4. In the VPC console, view the basic information about the vSwitch, such as the ID, zone, and VPC ID.
  5. Deploy Alibaba Cloud resources in the vSwitch.
    For more information, see Create cloud resources in a vSwitch.

Step 4: (Optional) Update the stack

If you want to update resources in a stack, you can update the stack. For example, you can update the name of the VPC in a stack.

  1. Log on to the ROS console. In the left-side navigation pane, click Stacks.
  2. On the Stacks page, find the stack whose resources you want to update, and click Update in the Actions column.
  3. In the Configure Template Parameters step, update the parameter configurations. In this example, VpcName is changed to testVPC.
  4. Click Confirm.

Step 5: (Optional) Delete the stack

You can delete a stack that you no longer need and release resources in the stack to prevent unnecessary costs.

  1. Log on to the ROS console. In the left-side navigation pane, click Stacks.
  2. On the Stacks page, find the stack that you want to delete, and click Delete in the Actions column.
  3. In the Delete Stack dialog box, set Method to Delete the Stack to Release Resources.
  4. Click OK.