All Products
Search
Document Center

Resource Orchestration Service:How to transform a Terraform template into a ROS-supported Terraform-type template?

Last Updated:Jun 17, 2026

Resource Orchestration Service (ROS) does not directly support standard Terraform templates. You can use the alibabacloud-ros-tran tool to transform a Terraform template into a Terraform-type template that ROS supports.

Prerequisites

The alibabacloud-ros-tran tool must be installed.

For more information, see ROS Template Transformer.

Terraform template

For more information about Terraform templates, see Introduction to Terraform.

main.tf

# Configure the AliCloud Provider
provider "alicloud" {}

# Create VPC and VSwitch
resource "alicloud_vpc" "myvpc" {
  cidr_block = "172.16.0.0/12"
  name       = "myvpc"
}

resource "alicloud_vswitch" "myvswitch" {
  vpc_id            = alicloud_vpc.myvpc.id
  cidr_block        = "172.16.0.0/21"
  availability_zone = "cn-beijing-g"
  name              = "myvswitch"
}

output.tf

output "vpc_id" {
  value = alicloud_vpc.myvpc.id
}

output "vswitch_id" {
  value = alicloud_vswitch.myvswitch.id
}

Transformation steps

Run the following command to transform a Terraform template into a ROS-supported Terraform-type template:

rostran transform templates/terraform/alicloud -S terraform  --compatible

Parameters

  • templates/terraform/alicloud: The path to your local Terraform template.

  • -S: The format of the source template file. In this example, the format is `terraform`. Supported formats include `auto` (default), `terraform`, `excel`, and `cloudformation`. By default, the source file format is determined by the file extension of `SOURCE_PATH`.

  • --compatible: Enables compatibility mode for the transformation. In compatibility mode, the content of the Terraform file is retained in the generated ROS template. Otherwise, the template is transformed to use ROS syntax. This option applies only to Terraform template files.

Terraform-type template

The following example shows the ROS-supported Terraform-type template generated after transformation. For more information about the template structure, see Terraform-type template structure.

ROSTemplateFormatVersion: '2015-09-01'
Transform: Aliyun::Terraform-v1.2
Workspace:
  main.tf: |
    # Configure the AliCloud Provider
    provider "alicloud" {}

    # Create VPC and VSwitch
    resource "alicloud_vpc" "myvpc" {
      cidr_block = "172.16.0.0/12"
      name       = "myvpc"
    }

    resource "alicloud_vswitch" "myvswitch" {
      vpc_id            = alicloud_vpc.myvpc.id
      cidr_block        = "172.16.0.0/21"
      availability_zone = "cn-beijing-g"
      name              = "myvswitch"
    }
  output.tf: |
    output "vpc_id" {
      value = alicloud_vpc.myvpc.id
    }

    output "vswitch_id" {
      value = alicloud_vswitch.myvswitch.id
    }