All Products
Search
Document Center

Resource Orchestration Service:Getting started

Last Updated:Apr 13, 2023

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: Create a template

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

For more information about template structures, see Template structure and Structure of Terraform templates.

The following sample code provides an example on how to create a template that is used to create a VPC and a vSwitch:

Create 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 section 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 provides information such as the scenarios and architecture of the template. We recommend that you specify a detailed description to help better understand the content of 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 how to define parameters, 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 the Parameters section are referenced by the properties in the Resources section. For more information about resources, see ALIYUN::ECS::VPC and ALIYUN::ECS::VSwitch.

  • Outputs: the resource information to be returned after the stack is created. In this example, the information about the VPC ID and the vSwitch ID is returned.

Step 2: Create a stack

If you want to quickly create a stack, you can use the template that is compiled in Step 1: Create 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 the 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 select Enter Template Content in the Template Import Method section. In the Template Content section, click the ROS tab and enter the content of the JSON template that you created in Step 1: Create a template. Then, click Next.

  6. In the Configure Template Parameters step, configure the Stack Name parameter and the following parameters. Then, click Next.

    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 of the stack.

    A tag is a key-value pair. You can add up to 20 tags. You can leave the tag value empty.

    [{"Key": "ros", "Value": "beginner-tutorial"}]

  7. In the Compliance Precheck step, complete compliance precheck and click Next.

    Note

    The compliance precheck feature is available only for specific resources. For more information, see Compliance precheck of ROS.

    1. In the Evaluate Rules section, add an evaluation rule.

      You can add evaluation rules based on the cloud resources in the ROS template.

    2. Click Evaluate.

      You can modify the template content based on the suggestions that are provided to remediate invalid resources to ensure the compliance of the resources.

  8. 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 Deploy 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 that 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.