All Products
Search
Document Center

Resource Orchestration Service:Get started with stacks

Last Updated:Sep 12, 2024

This topic describes the basic operations that you can perform in Resource Orchestration Service (ROS) to help you get started with ROS. For example, you can create a template, and create, view, and delete a stack in ROS.

Prerequisites

An Alibaba Cloud account is created. If you do not have an Alibaba Cloud account, go to the account creation page to create an account.

Sample scenario

If you want to deploy multiple cloud resources and their dependencies at the same time, or deploy cloud resources that have the same dependencies across regions, you can use ROS to achieve automated deployment. The cloud resources include Elastic Compute Service (ECS) instances and virtual private clouds (VPCs). This topic describes how to create a VPC and a vSwitch by using ROS.

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 and resource configurations, and declare dependency relationships between the resources in the template. You can create a custom template that follows the required template structure and includes the desired resource types. You can also use a sample template. For more information about how to create a template, see Getting started with template creation. For more information about template structures, see Structure of JSON and YAML templates and Structures of Terraform templates.

The following sample code provides an example on how to create a YAML template. In this example, the template 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 template includes the following sections:

  • ROSTemplateFormatVersion: the format version of the template. In this example, the format version 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 of the template. In this example, the following parameters are defined: VpcName, VpcCidrBlock, ZoneId, VSwitchName, VSwitchCidrBlock, and Tags. For more information about how to define parameters, see Overview.

  • Resources: the Alibaba Cloud resources that are included in the template. In this example, a VPC and a vSwitch are included. The parameters defined in the Parameters section are referenced by resource properties. For more information, see Resources, ALIYUN::ECS::VPC, and ALIYUN::ECS::VSwitch.

  • Outputs: the resource information that you want to obtain after the stack is created. In this example, the VPC ID and the vSwitch ID are obtained. For more information, see Outputs.

Step 2: Create a stack

  1. Log on to the ROS console.

  2. In the left-side navigation pane, click Stacks.

  3. In the top navigation bar, select the region where you want to create a stack from the region drop-down list. In this example, China (Hangzhou) is selected.

  4. On the Stacks page, click Create Stack and select Use ROS from the drop-down list.

  5. In the Select Template step, select Select an Existing Template in the Specify Template section and set the Template Import Method parameter to Enter Template Content. On the ROS tab in the Template Content section, enter the YAML template that you created in Step 1: Create a template. Then, click Next.

  6. In the Configure Parameters step, specify the Stack Name parameter, configure the following template parameters, and then click Next.

    For more information about how to configure the parameters in the Configure Stack Settings section, see Create a stack.

    Parameter

    Description

    Example

    VpcName

    The VPC name.

    myVPC

    VpcCidrBlock

    The CIDR block of the VPC. Valid values:

    • 10.0.0.0/8

    • 172.16.0.0/12

    • 192.168.0.0/16 (default)

    192.168.0.0/16

    ZoneId

    The zone ID.

    Hangzhou Zone K

    VSwitchName

    The vSwitch name.

    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 CIDR block must belong to the VPC CIDR block.

    192.168.0.0/24

    Tags

    The tags.

    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. Click Create.

Step 3: View the stack

  1. In the left-side navigation pane, click Stacks.

  2. In the top navigation bar, select the region where the stack you want to manage resides from the region drop-down list. In this example, China (Hangzhou) is selected.

  3. On the Stacks page, find the stack and click the stack ID in the Stack Name column.

    On the stack management page, you can perform the following operations to view the stack information:

    • Click the Stack Information tab to view information in the Basic Information and Stack Policy sections.

    • Click the Events tab to view events that occur during the stack lifecycle.

    • Click the Resources tab to view information about each resource in the stack.

    • Click the Outputs tab to view information about the outputs specified in the template when you created the stack.

    • Click the Parameters tab to view parameters specified in the template when you created the stack, including the ROS pseudo parameters that start with ALIYUN::.

    • Click the Drifts tab to view information in the Stack Drift Status and Resource Drift Status sections.

    • Click the Template tab to view the template of the stack.

    • Click the Change Sets tab to view the change sets of the stack.

Step 4: Use resources of the stack

After the stack is created, you can use the resources that are contained in the stack based on your business requirements. For example, you can deploy Alibaba Cloud resources in the vSwitch of the 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 that you want to manage.

  3. Click the Resources tab and the vSwitch ID.

  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.

Step 5: (Optional) Update the stack

If you want to update resources in a stack, you can update the stack. In this example, the value of the VpcName parameter is updated.

  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 section of the Configure Parameters step, update the parameter configurations. In this example, the value of the VpcName parameter is updated to testVPC.

  4. Click Confirm.

Step 6: (Optional) Delete the stack

You can delete a stack that you no longer require and release resources from 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 the Method to Delete the Stack parameter to Release Resources.

  4. Click OK.

What to do next

  • Familiarize yourself with the complete process of creating a stack. For more information, see Create a stack.

  • Deploy a stack across accounts and regions. For more information, see Overview.

  • Preview the architecture of resources and manage resources on a visualized interface. For more information, see Overview.

  • Familiarize yourself with the template syntax and structure. For more information, see Getting started with templates and Structure of Terraform templates.

  • Manage existing resources. For more information, see Overview.