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:
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
, andTags
. 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 theParameters
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.
Log on to the ROS console.
In the left-side navigation pane, click Stacks.
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.
On the Stacks page, click Create Stack and select Use New Resources (Standard) from the drop-down list.
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.
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
NoteThe 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"}]
In the Compliance Precheck step, complete compliance precheck and click Next.
NoteThe compliance precheck feature is available only for specific resources. For more information, see Compliance precheck of ROS.
In the Evaluate Rules section, add an evaluation rule.
You can add evaluation rules based on the cloud resources in the ROS template.
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.
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.
Log on to the ROS console. In the left-side navigation pane, click Stacks.
On the Stacks page, click the ID of the stack whose resources you want to use.
Click the Resources tab and the ID of the vSwitch.
In the VPC console, view the basic information about the vSwitch, such as the ID, zone, and VPC ID.
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.
Log on to the ROS console. In the left-side navigation pane, click Stacks.
On the Stacks page, find the stack that you want to update and click Update in the Actions column.
In the Configure Template Parameters step, update the parameter configurations. In this example, VpcName is changed to testVPC.
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.
Log on to the ROS console. In the left-side navigation pane, click Stacks.
On the Stacks page, find the stack that you want to delete and click Delete in the Actions column.
In the Delete Stack dialog box, set Method to Delete the Stack to Release Resources.
Click OK.