Learn how to write a template, create a stack, view a stack, and delete a stack in Resource Orchestration Service (ROS). This guide helps you get started with ROS.
Prerequisites
Make sure that you have an Alibaba Cloud account. If you do not have one, create an account.
Example scenario
If you want to deploy multiple cloud resources and their dependencies at the same time, or deploy cloud resources with the same dependencies across multiple regions, such as ECS instances and VPC-connected instances, you can use Resource Orchestration Service to automate deployment. In this topic, a virtual private cloud (VPC) and a vSwitch are created as an example.
Step 1: Write a template
A template is a text file in JSON, YAML, or Terraform format that uses UTF-8 encoding. In a template, you define Alibaba Cloud resources, configure their properties, and specify their dependencies. ROS then creates 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 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.
The following code provides a sample YAML template for creating a VPC and a vSwitch:
The following describes the template:
-
ROSTemplateFormatVersion: The version number of the template. The current version is 2015-09-01. -
Description: The description of the template. You can use this section to describe the scenario and architecture of the template, which helps users understand its purpose. -
Parameters: The parameters of the template. In this example, parameters are defined for the VPC name (VpcName), VPC CIDR block (VpcCidrBlock), zone ID (ZoneId), vSwitch name (VSwitchName), vSwitch CIDR block (VSwitchCidrBlock), and tags (Tags). For more information about how to define parameters, see Parameters. -
Resources: The Alibaba Cloud resources that are defined in the template. In this example, a VPC and a vSwitch are created. The properties of these resources reference the parameters that are defined in theParameterssection. For more information, see Resources, ALIYUN::ECS::VPC, and ALIYUN::ECS::VSwitch. -
Outputs: The resource information that is returned after the stack is created. In this example, the VPC ID and vSwitch ID are returned. 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. Set Template Import Method to Enter Template Content. On the ROS tab in the Template Content section, enter the YAML template from Step 1: Write a template. Then, click Next.
-
On the Configure Parameters page, enter a stack name, configure the template parameters, and then click Next.
For information about how to configure stack properties, 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 vSwitch and the VPC must be in the same CIDR block.
192.168.0.0/24
TagsThe tags.
You can specify a maximum of 20 tags. Each tag consists of a key-value pair. The tag value can be empty.
[{"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. For example, you can deploy Alibaba Cloud resources in the vSwitch of the VPC.
-
In the navigation pane on the left of the ROS console, click Stacks.
-
On the Stacks page, click the ID of the destination stack.
-
Click the Resources tab, and then click the vSwitch resource ID.
-
In the VPC console, view the basic information about the vSwitch, such as the vSwitch ID, zone, and the ID of the VPC to which the vSwitch belongs.
-
You can deploy Alibaba Cloud resources in a vSwitch.
For more information, see Create cloud resources.
Step 5 (Optional): Update a stack
You can update a stack to modify its resources, such as changing the value of VpcName.
-
In the navigation pane on the left of the ROS console, click Stacks.
-
On the Stacks page, find the destination stack and click Update in the Actions column.
-
On the Configure Template Parameters page, update the parameters. For example, change the value of VpcName to testVPC.
-
Click Modify.
Step 6 (Optional): Delete a stack
When you no longer need the created resources, you can delete the stack to release the resources and avoid unnecessary charges.
-
In the navigation pane on the left of the ROS console, click Stacks.
-
On the Stacks page, find the destination stack and click Delete in the Actions column.
-
In the Delete Stacks dialog box, set Method to Delete the Stack to Release Resources.
-
Click OK.
What to do next
-
To learn about the complete process of creating a stack, see Create a stack.
-
To deploy stacks across accounts and regions, see Stack groups.
-
To preview the overall resource architecture and manage resources visually, see Resource scenarios.
-
For information about template syntax and structure, see Template syntax and Terraform template structure.
-
To manage existing resources, see Resource import.