A template is a UTF-8 encoded JSON or YAML file that is used to create stacks. Templates serve as the blueprint for underlying infrastructure and architecture. Templates define the configurations and dependencies of Alibaba Cloud resources.

ROS template structure

ROSTemplateFormatVersion: '2015-09-01'
Description: The description of the template. The Description section provides information such as scenarios and the template architecture.
Metadata:
# The metadata of the template. The Metadata section provides information such as layouts for visualizations.
  Parameters: 
  # The custom parameters that you can specify in the template when you create a stack.
  Mappings: 
  # The mappings of the template. Mappings are key-value pairs in a nested structure. 
  Conditions: 
  # The conditions of the template. The Conditions section determines when to create associated resources. You can define conditions by using internal condition functions.
  Resources: 
  # The resources of the template. The Resources section contains detailed information about resources, such as dependencies and configurations.
  Outputs: 
  # The outputs of the template. The Outputs section returns useful information such as resource properties. You can obtain the outputs by using the Resource Orchestration Service (ROS) console or by calling specific ROS API operations.
  Rules: 
  # The rules of the template. When you create or update a stack based on the template, you can use rules to check whether the values passed to the parameters are valid.

ROSTemplateFormatVersion

Required. The template versions that are supported by ROS. Current version: 2015-09-01.

Description

Optional. The description of the template, which is used to provide information such as the application scenarios and architecture of the template. A detailed description can help you better understand the content of the template.

Metadata

Optional. The metadata of the template, in the JSON format.

Parameters

Optional. The parameters you can specify when you create a stack. An ECS instance type is often defined as a parameter. Parameters have default values. Parameters can improve the flexibility and reusability of the template. When you create a stack, select appropriate specifications.

For more information, see Parameters.

Mappings

Optional. Mappings are defined as nested mapping tables. You can use Fn::FindInMap to match a key to a corresponding set of named values. You can also use parameter values as keys. For example, you can search the region-image mapping table for desired images by region.

For more information, see Mappings.

Conditions

Optional. The conditions that are defined by using Fn::And, Fn::Or, Fn::Not, and Fn::Equals. Separate multiple conditions with commas (,). When you create or update a stack, ROS evaluates all the conditions in your template before it creates any resources. All resources associated with true conditions are created, and all resources associated with false conditions are ignored.

For more information, see Conditions.

Resources

Optional. The detailed information of resources in the stack that is created based on the template. The information includes resource dependencies and configurations.

For more information, see Resources.

Outputs

Optional. The outputs that are used to provide useful information such as resource properties. You can use the ROS console or API to obtain the information.

For more information, see Outputs.

Rules

Optional. When you create or update a stack based on the template, you can use rules to check whether the values passed to the parameters are valid.

For more information, see Rules.