Convert an Excel template to a ROS template by using the rostran CLI. This example uses an ECS instance group template.
Syntax of an Excel template
Enter parameters, resource types, and property values in the first sheet of an Excel workbook.
Note the following items:
-
Column A: parameters, resource types, and their properties.
Resource type
Required
Description
ROS::ParametersNo
Parameters in the ROS template.
Enter parameter names under
ROS::Parameters. In Columns B to N, enter!Refto reference parameters.ROS::ResourcesYes
Resources in the ROS template.
Under
ROS::Resources, enter resource types and their property names to define resources for templates.For more information about resource types, see Resource type index.
-
Columns B to N: parameter values and resource property values. Each column generates one template.
The Excel template supports comments:
-
A row starting with
#is treated as a comment. -
If a commented cell contains a resource type, all wrapped content in that cell is also commented.
Step 1: Modify the Excel template file
Modify the Excel template file based on the syntax above. Download the sample EcsInstance.xlsx for reference.
In this example, Columns B and C contain values, so two templates are generated.
Step 2: Convert the template
Run the following command to convert the Excel template to a ROS template. The output file template-{number}.json is generated in the same directory as the Excel file.
{number} is a zero-based integer. template-0.json corresponds to Column B, and template-1.json corresponds to Column C.
rostran transform templates/excel/EcsInstance.xlsx --target-path tests/template.json
Step 3: View the ROS template
This example generates template-0.json and template-1.json:
-
template-0.json{ "ROSTemplateFormatVersion": "2015-09-01", "Parameters": { "ZoneId": { "Type": "String", "Default": "cn-beijing-h" }, "SystemDiskSize": { "Type": "Number", "Default": 100 } }, "Resources": { "MyInstance": { "Type": "ALIYUN::ECS::InstanceGroup", "Properties": { "RegionId": "cn-beijing", "ZoneId": "cn-beijing-h", "ChargeType": "PostPaid", "InstanceType": "ecs.g5.large", "Amount": 200, "SystemDiskCategory": "cloud_efficiency", "SystemDiskSize": 100, "DiskMappings": [{ "Category": "cloud_ssd", "Size": 200 }], "ImageId": "EasyShopLinux2019****", "Password": "pass****", "VpcId": { "Ref": "MyVpc" }, "VSwitchId": { "Ref": "MyVSwitch" }, "InternetMaxBandwidthOut": 0, "SecurityGroupId": "sg-2zej2g9ep36k3yhh****" } }, "MyVpc": { "Type": "ALIYUN::ECS::Vpc", "Properties": { "VpcName": "MyVpcName" } }, "MyVSwitch": { "Type": "ALIYUN::ECS::VSwitch", "Properties": { "VpcId": { "Ref": "MyVpc" }, "ZoneId": "cn-beijing-h", "VSwitchName": "MyVSwitchName" } } } } -
template-1.json{ "ROSTemplateFormatVersion": "2015-09-01", "Parameters": { "ZoneId": { "Type": "String" }, "SystemDiskSize": { "Type": "Number" } }, "Resources": { "MyInstance": { "Type": "ALIYUN::ECS::InstanceGroup", "Properties": { "RegionId": "cn-beijing", "ZoneId": { "Ref": "ZoneId" }, "ChargeType": "PostPaid", "InstanceType": "ecs.r5.6xlarge", "Amount": 50, "SystemDiskCategory": "cloud_ssd", "SystemDiskSize": 100, "DiskMappings": [{ "Category": "cloud_ssd", "Size": 200 }], "ImageId": "EasyShopLinux2019****", "Password": "password", "VpcId": "vpc-bp1397wjfjjzlck86****", "VSwitchId": "vsw-bp1apypxlcxdao9w7****", "InternetMaxBandwidthOut": 0, "SecurityGroupId": "sg-2zej2g9ep36k3yhh****" } } } }