Resource Orchestration Service (ROS) allows you to manage resources by using Terraform.
You can create Terraform templates to define Alibaba Cloud, AWS, and Azure resources,
specify resource parameters, and configure dependencies between 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, choose Templates > My Templates.
- On the My Templates page, click Create Template.
- In the Create Template dialog box, set Template Name and Template Description.
- Set Template Import Method to Enter Template Content and set Template Content to Terraform.
- Write a Terraform template.
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 then 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 then 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}"
}

- Click OK.