Resource Orchestration Service (ROS) allows you to manage resources by using Terraform.
You can create Terraform stacks to orchestrate Alibaba Cloud, AWS, and Azure resources.
Background information
For more information about the structure of Terraform templates, see Terraform template structure.
Procedure
- 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 where you want to create the
stack from the drop-down list.
- On the Stacks page, click Create Stack and select Use New Resources (Standard) from the drop-down list.
- In the Select Template step of the Create Stack wizard, click Select an Existing Template in the Specify Template section.
- Set Template Import Method to Enter Template Content and set Template Content to Terraform.
- Write a Terraform template and click Next.
In the following example, a vSwitch is created within a VPC to show how to write a
Terraform template.
- Create a file named main.tf in the
modules/vpc/ directory
and edit its content to create a VPC.
- Click the + icon to the right of Directory and select Create Folder.

- In the Create Folder dialog box, enter modules and click OK. A folder named modules is displayed in the
directory.
- Move the pointer over the modules folder, click the + icon to its right, and then select Create Folder.
- In the Create Folder dialog box, enter
vpc
and click OK. A folder named vpc is displayed under the modules folder.
- Move the pointer over the
vpc
folder, click the + icon to its right, and then select Create File. 
- In the Create File dialog box, enter main.tf and click OK. A file named main.tf is displayed under the
vpc
folder.
- Click main.tf and enter the following code in the right-side field to create a VPC:
resource "alicloud_vpc" "vpc" {
name = "tf_test"
cidr_block = "172.16.0.0/12"
}
output "vpc_id" {
value = "${alicloud_vpc.vpc.id}"
}

- Edit the main.tf file in the root directory to create a vSwitch in the VPC.
- Click the main.tf file in the root directory.
- Enter the following code in the right-side field to create a vSwitch:
module "my_vpc" {
source = "./modules/vpc"
}
resource "alicloud_vswitch" "vsw" {
vpc_id = "${module.my_vpc.vpc_id}"
cidr_block = "172.16.0.0/21"
availability_zone = "cn-shanghai-b"
}
output "vsw_id" {
value = "${alicloud_vswitch.vsw.id}"
}
Note The availability_zone
parameter must be set to a zone within the region in which the stack resides.

- In the Configure Template Parameters step of the Create Stack wizard, set Stack Name and click Next.
- In the Configure Stack step of the Create Stack wizard, set Timeout Period, Deletion Protection, and Tags, and then click Next.
- In the Check and Confirm step of the Create Stack wizard, click Create.
Note After the stack is created, you can go to the Stacks page. Click the stack ID in the Stack Name column to go to the stack management page. On the page that appears, you can click
the Stack Information, Events, Resources, Outputs, and Template tabs to view information
of the stack.