All Products
Search
Document Center

Resource Orchestration Service:Common commands for Template Transformer

Last Updated:Aug 29, 2023

This topic describes the common commands that you can run in Template Transformer of Resource Orchestration Service (ROS).

View help information

Run the following command to view the help information about Template Transformer:

rostran --help

Convert a template

Run the following command to convert a template:

rostran transform SOURCE_PATH [OPTIONS]

The following table describes the parameters in the command.

Parameter

Required

Description

SOURCE_PATH

Yes

The path in which the original template file is stored. The original template can be an Excel, Terraform, or AWS CloudFormation template.

OPTIONS

No

Valid values:

  • --source-format: the format of the original template file. The original file format varies based on the suffix of the SOURCE_PATH value. Valid values:

    • auto (default)

    • terraform

    • excel

    • cloudformation

    The following sample code provides an example on how to convert a Terraform template to a ROS template. In the code, the format of the original template file is set to terraform. The original template file is named main.tf.

    rostran transform templates/terraform/alicloud --source-format terraform
  • --target-path: the path in which the ROS template file is generated. By default, the value of this parameter is the directory in which the original template is stored. Valid values:

    • A specific directory: In the directory, the ROS template file named template is generated.

    • A specific path: In the path, the ROS template file with a custom name is generated. The ROS template file must be in the JSON or YAML format.

  • --target-format: the format of the ROS template that is generated. Valid values:

    • auto (default)

      Note

      If you set --target-path to a specific path, the --target-format value is the same as the format of the file that is stored in the path. If you set --target-path to a specific directory, the name of the generated ROS template is template.yml.

    • json

    • yaml

    The following sample code provides an example on how to convert a Terraform template to a ROS template and generate a JSON ROS template file named template.json in the directory:

    rostran transform templates/terraform/alicloud/main.tf --target-format json

The following items provide examples of converting different types of templates to ROS templates:

Format a template

Run the following code to format a template:

rostran format [OPTIONS] PATH...

The following tables describe the parameters in the code.

Parameter

Required

Description

PATH

Yes

The path of the ROS template file that you want to format.

Note

You can specify multiple template file paths.

OPTIONS

No

Valid values:

  • --replace: replaces the content of the source file with the formatted content.

  • --no-replace (default): only displays formatted content.

  • --skip PATH: specifies the path of the ROS template file that you want to skip from the format operation.

    Note

    You can specify multiple template file paths.

Formatting rules

The sections of a template are formatted in the following sequence: ROSTemplateFormatVersion, Transform, Description, Conditions, Mappings, Parameters, Resources, Outputs, Metadata, and Workspace.

The following items describe the sorting order for data in each template section:

  • Conditions: Conditions are sorted in ascending alphabetical order.

  • Mappings: Mappings are sorted in ascending alphabetical order.

  • Parameters: Parameters are sorted based on the sequence that is defined in Metadata.ALIYUN::ROS::Interface.ParameterGroups.Parameters. If Metadata.ALIYUN::ROS::Interface.ParameterGroups.Parameters is not defined, the parameters are not sorted. The properties of each parameter are sorted in specific orders, such as in the order of type, description, and constraint.

  • Resources: Resources are sorted in the order of the resource dependency. Dependencies are arranged before resources. Resource properties are sorted in the default order.

  • Outputs: Output properties are sorted in the following order: Description, Condition, and Value.

  • Metadata: Metadata entries are sorted in the following order: ALIYUN::ROS::Interface, ALIYUN::ROS::Designer, and PredefinedParameters. The properties of each metadata entry are sorted in the default order.

  • Workspace: Workspaces are sorted in ascending alphabetical order. main.tf is arranged in the first place.