With Resource Orchestration Service (ROS), you define a group of Alibaba Cloud resources in a template and deploy them as a single stack. This topic describes the template-based workflow in the ROS console, from writing a template to deleting the stack.
Prerequisites
Make sure that you have an Alibaba Cloud account. If you do not have one, create an account.
Example scenario
If you need to deploy multiple cloud resources and their dependencies at the same time, or deploy cloud resources that have the same dependencies in multiple regions, such as ECS instances and VPC-connected instances, use ROS to automate the deployment. This topic uses the quick creation of a virtual private cloud (VPC) and a vSwitch as an example.
Step 1: Write a template
A template is a text file in the JSON, YAML, or Terraform format that uses UTF-8 encoding. Use a template to define Alibaba Cloud resources and their configuration details, specify the dependencies between the resources, and then create a stack based on the template. You can write a template based on the template structure and resource types, or use a sample template. For more information about how to write a template, see Quick start for writing a template. For more information about template structures, see JSON and YAML template structure and Terraform template structure.
This topic uses the following sample YAML template, which creates a VPC and a vSwitch:
The following describes the template:
-
ROSTemplateFormatVersion: The version number of the template. The current version number is 2015-09-01. -
Description: The description of the template. Use this section to describe scenarios in which the template applies and the architecture that the template creates. A detailed description helps users understand the content of the template. -
Parameters: The parameters of the template. This example defines parameters for the VPC name (VpcName), the VPC CIDR block (VpcCidrBlock), the zone ID (ZoneId), the vSwitch name (VSwitchName), the vSwitch CIDR block (VSwitchCidrBlock), and tags (Tags). For more information about how to define parameters, see Parameters. -
Resources: The Alibaba Cloud resources that the template contains. This example creates one VPC and one vSwitch. The resource properties reference the parameters that are defined inParameters. For more information, see Resources, ALIYUN::ECS::VPC, and ALIYUN::ECS::VSwitch. -
Outputs: The resource information that is returned after the stack is created. This example returns the VPC ID and the vSwitch ID. For more information, see Outputs.
Step 2: Create a stack
-
Log in to the ROS console.
-
In the left-side navigation pane, click Stacks.
-
In the top navigation bar, select a region from the region drop-down list, such as China (Hangzhou).
-
On the Stacks page, click Create Stack. In the Specify Template section, click Select an Existing Template.
Note-
If you select Create Template or ROS Infrastructure Composer, you are redirected to the corresponding page.
-
-
On the Specify Template page, click Select an Existing Template in the Specify Template section. To paste the template content directly into the console, set Template Import Method to Enter Template Content. On the ROS tab of the Template Content section, enter the YAML template that you wrote in Step 1: Write a template. Then, click Next.
-
On the Configure Parameters page, enter a stack name, configure the following template parameters, and then click Next.
For details about the stack properties that you configure in this step, see Create a stack.
Parameter
Description
Example
VpcNameThe name of the VPC.
myVPC
VpcCidrBlockThe 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
ZoneIdThe ID of the zone.
Zone K in the China (Hangzhou) region
VSwitchNameThe name of the vSwitch.
myVSwitch
VSwitchCidrBlockThe CIDR block of the vSwitch. Valid values:
-
10.0.0.0/24
-
172.16.0.0/24
-
192.168.0.0/24
NoteThe CIDR block of the vSwitch must be within the CIDR block of the VPC that the vSwitch belongs to.
192.168.0.0/24
TagsThe tags.
You can specify a maximum of 20 tags. Each tag is a key-value pair. The tag value can be left blank.
[{"Key": "ros", "Value": "beginner-tutorial"}]
-
-
Click Create.
Step 3: View a stack
In the left-side navigation pane, click Stacks.
-
In the top navigation bar, select a region from the region drop-down list, such as China (Hangzhou).
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 Event 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 Output tab to view information about the outputs specified in the template when you created the stack.
Click the Parameter tab to view parameters specified in the template when you created the stack, including the ROS pseudo parameters that start with
ALIYUN::.Click the Drift tab to view information in the Stack Drift Status and Resource Drift Status sections.
Click the Templates 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 in the stack
After the stack is created, you can use the resources in the stack as needed. For example, you can deploy Alibaba Cloud resources in the vSwitch of the VPC.
-
In the left-side navigation pane of the ROS console, click Stacks.
-
On the Stacks page, click the ID of the stack that you want to view.
-
Click the Resources tab, and then click the ID of the vSwitch resource.
-
In the VPC console, view the basic information about the vSwitch, including the vSwitch ID, the zone, and the ID of the VPC to which the vSwitch belongs.
-
Deploy Alibaba Cloud resources in the vSwitch.
For more information, see Create cloud resources.
Step 5 (Optional): Update a stack
When you need to modify a resource in a stack, such as VpcName, update the stack.
-
In the left-side navigation pane of the ROS console, click Stacks.
-
On the Stacks page, find the stack that you want to update and click Update in the Actions column.
-
On the Configure Template Parameters page, update the parameters. For example, change the value of
VpcNametotestVPC. -
Click Modify.
Step 6 (Optional): Delete a stack
When you no longer need the resources that you created, delete the stack to release the resources and avoid unnecessary costs.
When you delete the stack and release its resources, the VPC and the vSwitch that the stack created are released. Make sure that you no longer need these resources before you continue.
-
In the left-side navigation pane of the ROS console, click Stacks.
-
On the Stacks page, find the stack that you want to delete and click Delete in the Actions column.
-
In the Delete Stacks dialog box, set Method to Delete the Stack to Release Resources to release the resources that the stack created.
-
Click OK.
What to do next
-
To learn about the complete process of creating a stack, see Create a stack.
-
To deploy stacks in cross-account and cross-region scenarios, see Stack groups.
-
To preview the overall resource architecture and manage resources in a visualization scenario, see Resource scenarios.
-
For more information about template syntax and structure, see Template syntax and Terraform template structure.
-
To manage existing resources, see Resource import.