Common commands for the Template Transformer

更新时间:
复制 MD 格式

Use ROS Template Transformer commands to convert Excel, Terraform, or AWS CloudFormation templates into ROS templates and format existing ROS templates.

View help information

Run the following command to view help information for Template Transformer.

rostran --help

Transform a template

Run the following command to transform a template.

rostran transform SOURCE_PATH [OPTIONS]

The following table describes the parameters.

Parameter

Required

Description

SOURCE_PATH

Yes

The path of the source template file. The source template can be in Excel, Terraform, or AWS CloudFormation format.

OPTIONS

No

Valid values:

  • --source-format: The format of the source template file. The format is determined by the file extension of SOURCE_PATH. Valid values:

    • auto (default)

    • terraform

    • excel

    • cloudformation

    For example, the following command transforms a Terraform template into an ROS template with the source format specified as Terraform:

    rostran transform templates/terraform/alicloud --source-format terraform
  • --target-path: The path where the ROS template is generated. The default path is the current folder. Valid values:

    • A folder: An ROS template named template is generated in the folder.

    • A file path: An ROS template with the specified file name is generated. The file must be in JSON or YAML format.

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

    • auto (default)

      Note

      If you set --target-path to a file path, the format of the generated ROS template is the same as the file format specified in --target-path. If you set --target-path to a folder, an ROS template named template.yml is generated.

    • json

    • yaml

    For example, the following command transforms a Terraform template and generates a template.json file in JSON format in the current folder:

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

Sample transform templates:

Format a template

Run the following command to format a template.

rostran format [OPTIONS] PATH...

The following table describes the parameters.

Parameter

Required

Description

PATH

Yes

The path of the ROS template file 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): Outputs only the formatted content.

  • --skip PATH: The path of the ROS template file to skip during formatting.

    Note

    You can specify multiple template file paths.

Formatting rules

The template sections are sorted in the following order: ROSTemplateFormatVersion, Transform, Description, Conditions, Mappings, Parameters, Resources, Outputs, Metadata, and Workspace.

The sorting rules for each section are as follows:

  • Conditions section: Sorted in ascending alphabetical order.

  • Mappings section: Sorted in ascending alphabetical order.

  • Parameters section: Sorted in the order defined in Metadata.ALIYUN::ROS::Interface.ParameterGroups.Parameters, if it exists. The properties of each parameter are sorted in the order of type, description, constraint, and other properties.

  • Resources section: Sorted by resource dependency, with dependent resources placed first. The properties of each resource are sorted according to specific rules.

  • Outputs section: The properties are sorted in the order of Description, Condition, and Value.

  • Metadata section: Sorted in the order of ALIYUN::ROS::Interface, ALIYUN::ROS::Designer, and PredefinedParameters. The value properties of each item are sorted according to specific rules.

  • Workspace section: Sorted in ascending alphabetical order, with main.tf always placed first.