All Products
Search
Document Center

Resource Orchestration Service:Template structure

Last Updated:Apr 25, 2023

A template is a UTF-8 encoded JSON or YAML file. Templates are used to create stacks and serve as the blueprints for underlying infrastructures and architectures. You can define Alibaba Cloud resources, configurations, and resource associations in Resource Orchestration Service (ROS) templates.

ROS template structure

ROSTemplateFormatVersion: '2015-09-01'
Description: The description of the template. The Description section provides information such as the scenarios and architecture of the template. 
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 mapping tables of the template. Mapping tables are nested tables. 
  Conditions: 
  # The conditions of the template, which are defined by using intrinsic condition functions. The conditions determine when the system can create associated resources. 
  Resources: 
  # The resources of the template. The Resources section contains the detailed information about resources, such as the associations and configurations of resources. 
  Outputs: 
  # The outputs of the template. The Outputs section declares the outputs that you want to obtain, such as resource properties. You can obtain outputs by using the ROS console or by calling specific ROS API operations. 
  Rules: 
  # The rules of the template. When you create or update a stack, the Rules section validates whether the parameter values that are passed to the template are valid.

(Required) ROSTemplateFormatVersion

The format version of the ROS template. Set the value to 2015-09-01.

(Optional) Description

The description of the template, which provides information such as the scenarios and architecture of the template. We recommend that you specify a detailed description to help better understand the content of the template.

(Optional) Metadata

The metadata of the template. Metadata can be in the JSON format.

(Optional) Parameters

The custom parameters that you can specify in the template when you create a stack. In most cases, an Elastic Compute Service (ECS) instance type is defined as a parameter. Parameters have default values. You can use parameters to improve the flexibility and reusability of your template. When you create a stack based on a template that contains the Parameters section, you can select an appropriate instance type.

For more information, see Parameters.

(Optional) Mappings

Mappings are defined as nested mapping tables. You can invoke the Fn::FindInMap function to return a named value based on a specified key. You can also input parameters as keys to find mappings in mapping tables. For example, you can use a region as a key to match the region to an appropriate image in a region-image mapping table.

For more information, see Mappings.

(Optional) Conditions

The conditions of the template. You can use the following functions to define conditions: Fn::And, Fn::Or, Fn::Not, and Fn::Equals. Separate multiple conditions with commas (,). ROS evaluates all conditions in the template before ROS creates or updates a stack. All resources associated with true conditions are created, and all resources associated with false conditions are ignored.

For more information, see Conditions.

(Optional) Resources

The detailed information about resources in the stack that is created based on the template. The information includes resource associations and configurations.

For more information, see Resources.

(Optional) Outputs

The outputs of the template. The Outputs section declares the outputs that you want to obtain, such as resource properties. You can obtain outputs by using the ROS console or by calling specific ROS API operations.

For more information, see Outputs.

(Optional) Rules

The rules of the template. When you create or update a stack, the Rules section validates whether the parameter values that are passed to the template are valid.

For more information, see Rules.

What to do next

Familiarize yourself with the best practices for templates. For more information, see Template deployment.