This topic describes how to write a template using the ROS online template editor. The online template editor provides features such as auto-completion for template content, parameter preview, and architecture diagram preview.
Prerequisites
Make sure you are familiar with ROS template syntax and structure. For more information, see template syntax and 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.
-
On the Create Template page, edit the ROS template.
You can edit the template in the ROS template editor or the Terraform template editor.
ROS template editor
The ROS template editor supports two modes: script editor and visual editor.
-
Script editor (for JSON and YAML templates)
The script editor supports features such as content auto-completion and parameter suggestions.
-
Intelligent suggestions for resource and parameter types
When you define resources (Resources) and parameters (Parameters) in a ROS template, the editor provides suggestions for the required resource and parameter types.
The editor supports auto-completion for both JSON and YAML formats. For example, when you enter a keyword for a resource type in the Resources section of a JSON template, options such as
ALIYUN::ECS::VPCappear. When you enter a parameter type in the Parameters section of a YAML template, suggested values such asBooleanappear. -
Intelligent suggestions for resource properties
When you define resources (Resources) in a ROS template, the editor provides suggestions for the required resource properties (Properties).
For example, when you define the properties for a resource of the
ALIYUN::ECS::VPCtype, entering the letterVdisplays a drop-down list of matching properties, such asVpcName. -
Intelligent suggestions for references
When you use the
Reffunction in the Resources, Outputs, Mappings, Conditions, or Metadata sections of a ROS template, the editor suggests matching parameters, resource IDs, and pseudo parameters.For example, if you enter
"Ref": "v", the editor displays a drop-down list of matching items, such as the resource name VPC, the parameter name VpcName, and the pseudo parameter ALIYUN::NoValue. -
Parameter information preview
After defining the ROS template, you can click the Preview button in the upper-right corner of the editor to preview the rendered template parameters. This allows you to review and refine the parameters.
The preview panel displays the parameters defined in the template in a form. This includes the parameter label (Label), type (Type), and default value (Default), along with the corresponding input controls such as text boxes and drop-down lists. This helps you visually verify the parameter configuration.
-
-
Visual editor
The visual editor supports features such as drop-down selection and text input.
The editor provides a visual interface to manually edit and generate a ROS template. You can use the visual template editing tree to update or delete template parameters, resources, metadata, and outputs.
The visual template editing tree displays nodes such as Mappings, Conditions, Resources, Outputs, and Metadata. In this example, a resource named Vpc of type
ALIYUN::ECS::VPCis defined under Resources and contains the VpcName and CidrBlock properties. The Outputs section defines three output items: VRouterId, RouteTableId, and VpcId. A quick navigation pane on the right allows you to jump to each node.
Terraform template editor
-
Import and edit Terraform templates
You can import an existing Terraform project by opening its folder in the Terraform editor.
-
Convert between Terraform and ROS templates
After you define a Terraform template and switch to the ROS template view, the code is converted to a format supported by ROS-hosted Terraform.
The converted ROS template is in JSON format. It includes the
ROSTemplateFormatVersion(set to2015-09-01),Transform(set toAliyun::Terraform-v1.2), and aWorkspaceobject. TheWorkspaceobject embeds your Terraform files, such as main.tf, into the ROS template.