This topic describes how to write a template, create a stack, view a stack, and delete a stack in Resource Orchestration Service (ROS) to help you get started quickly.
Prerequisites
An Alibaba Cloud account is required. If you do not have one, register an account.
Example scenario
You can use Resource Orchestration Service (ROS) to simultaneously deploy multiple cloud resources and their dependencies, or to deploy the same set of resources in multiple regions. For example, you can deploy ECS instances and VPC-connected instances. ROS provides automated deployment. This topic uses the 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 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. You can then create a stack based on the template. You can write your own template based on the template structure and supported 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 Structure of JSON and YAML templates and Structure of Terraform templates.
The following sample YAML template shows how to create 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 purpose and architecture of the resources that the template defines. A detailed description helps other users understand your template. -
Parameters: The parameters of the template. In this example, the parameters include the VPC name (VpcName), VPC CIDR block (VpcCidrBlock), zone ID (ZoneId), vSwitch name (VSwitchName), vSwitch CIDR block (VSwitchCidrBlock), and tags (Tags). For more information, see Parameters. -
Resources: The Alibaba Cloud resources that are defined in the template. In this example, a VPC and a vSwitch are created. The resource properties reference the parameters 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 on to the ROS console.
-
In the navigation pane on the left, click Stacks.
-
In the top navigation bar, select the region where you want to create the stack 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. In the Template Content section, click the ROS tab and enter the YAML template from Step 1: Write a template. Click Next.
-
On the Configure Parameters page, enter a stack name, configure the template parameters, and then click Next.
For more information about how to configure stack properties, see Create a stack.
Parameter
Description
Example
VpcNameName of the VPC.
myVPC
VpcCidrBlockCIDR 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
ZoneIdID of the zone.
China (Hangzhou) Zone K
VSwitchNameName of the vSwitch.
myVSwitch
VSwitchCidrBlockCIDR 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
TagsTags.
You can add up to 20 tags. Each tag is a key-value pair. The tag value can be empty.
[{"Key": "ros", "Value": "beginner-tutorial"}]
-
-
Click Create.
Step 3: View the stack
-
In the left-side navigation pane, click Stacks.
-
In the top navigation bar, select the region where you want to create the stack 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 other Alibaba Cloud resources in the vSwitch that belongs to the VPC.
-
In the navigation pane on the left of the ROS console, click Stacks.
-
On the Stacks page, click the ID of the stack that you created.
-
Click the Resources tab, and then click the resource ID of the vSwitch.
-
On the vSwitch details page in the VPC console, you can view basic information about the vSwitch, such as its ID, zone, and the ID of the VPC to which it belongs.
-
You can deploy Alibaba Cloud resources in the vSwitch.
For more information, see Create cloud resources.
Step 5 (Optional): Update the stack
To update resources in a stack, such as changing the VpcName, you can update the stack.
-
In the navigation pane on the left of the ROS console, click Stacks.
-
On the Stacks page, find the stack and click Update in the Actions column.
-
On the Configure Template Parameters page, modify the parameters. For example, change the value of VpcName to testVPC.
-
Click Modify.
Step 6 (Optional): Delete the stack
When you no longer need the resources in a stack, you can delete the stack. This releases the resources and helps you avoid unnecessary charges.
-
In the navigation pane on the left of the ROS console, click Stacks.
-
On the Stacks page, find the 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 resource architecture and manage resources visually, see Resource scenarios.
-
For information about template syntax and structure, see Template syntax and Structure of Terraform templates.
-
To manage existing resources, see Resource import.