Resource Orchestration Service (ROS) is an automated deployment service that is designed based on the concept of infrastructure as code (IaC). You can create a template in ROS to define the cloud resources that you want to use and the dependencies between the resources. Then, you can use the template to create a stack to automatically deploy the resources. This topic helps you get started with ROS and provides an example on how to create a virtual private cloud (VPC) and a vSwitch by using a template.
Prerequisites
An Alibaba Cloud account is created. If you do not have an Alibaba Cloud account, go to the account registration page to create an 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 YAML template. In this example, the template is used to create a VPC and a vSwitch.
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 that you define in the template. In this example, the following parameters are defined:VpcName
,VpcCidrBlock
,ZoneId
,VSwitchName
,VSwitchCidrBlock
, andTags
. For more information about how to define parameters, see Overview.Resources
: the Alibaba Cloud resources that are included in the template. In this example, the resources are a VPC and a vSwitch. The parameters defined inParameters
are referenced by the 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
If you want to quickly create a stack, you can use the template that is created in Step 1: Create a template. To create a stack, perform the following operations:
Log on to the ROS console.
In the left-side navigation pane, click Stacks.
In the top navigation bar, select the region where you want to create a stack from the region drop-down list. For example, select China (Hangzhou).
On the Stacks page, click Create Stack and select Use ROS from the drop-down list.
In the Select Template step, click Select an Existing Template in the Specify Template section, and set Template Import Method to Enter Template Content. Then, enter the YAML template that you created in Step 1: Create a template on the ROS tab in the Template Content code editor, and click Next.
In the Configure Template Parameters step, specify Stack Name, configure the following parameters, and then click Next.
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
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 the 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 compliance rules.
You can add compliance rules based on the cloud resources in the 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 the vSwitch of the 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 that you want to manage.
Click the Resources tab and the vSwitch ID.
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. In this example, the value of VpcName is updated.
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, the value of 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.