All Products
Search
Document Center

Resource Orchestration Service:Overview

Last Updated:Mar 04, 2024

When you create a template, you can add the Parameters section to improve the flexibility and reusability of the template. You can replace specific parameter values based on your business requirements when you use the template to create a stack.

Syntax

Each parameter consists of a parameter name and properties. A parameter name can contain only letters and digits and must be unique in the same template. You can use the Label property to define the alias of a parameter.

The following table describes the properties that are supported in the Parameters section.

Property

Required

Description

Type

Yes

The data type of a parameter. Valid values:

  • String: a string. Example: "ecs.s1.medium".

  • Number: an integer or a floating-point number. Example: 3.14.

  • CommaDelimitedList: a string that consists of multiple values. The values are separated by commas (,). You can use the Fn::Select function to return the values based on indexes. Example: "80, foo, bar".

  • Json: a JSON string. Example: {"foo": "bar"} or [1, 2, 3].

  • Boolean: a boolean value. Example: true or false.

  • ALIYUN::OOS::Parameter::Value: a common parameter that is stored in Parameter Store of CloudOps Orchestration Service (OOS). For more information, see Common parameters. Example: my_image.

  • ALIYUN::OOS::SecretParameter::Value: an encrypted parameter that is stored in OOS Parameter Store. For more information, see Encryption parameters. Example: my_password.

Note

You cannot use AllowedPattern to verify parameters of the ALIYUN::OOS::Parameter::Value and ALIYUN::OOS::SecretParameter::Value types.

Default

No

The default value of a parameter. If you do not specify a value for a template parameter when you create a stack, Resource Orchestration Service (ROS) checks whether a default value is defined for the parameter in the template. If a default value is defined in the template, ROS uses the default value. Otherwise, an error is reported.

Note

You can set the default value of a parameter in the template to null. In this case, this parameter is empty and the verification for this parameter is ignored.

AllowedValues

No

The valid values of a parameter.

AllowedPattern

No

A regular expression that represents the allowed pattern for the specified String-type parameters. If you do not specify a String-type parameter, an error is reported.

If you use one or more of the following special characters, add two backslashes (\\) as an escape character before each special character:

*.?+-$^[ ]( ){ }|\/
Note

You do not need to add an escape character before a hyphen (-) that is used as the first or last special character in a value range. Example: [a-z-].

MaxLength

No

An integer value that specifies the largest number of characters allowed for a String-type parameter.

MinLength

No

An integer value that specifies the smallest number of characters allowed for a String-type parameter.

MaxValue

No

A numeric value that specifies the largest numeric value allowed for a Number-type parameter.

MinValue

No

A numeric value that specifies the smallest numeric value allowed for a Number-type parameter.

NoEcho

No

If you set the NoEcho property of a parameter to true, ROS returns the parameter value masked as asterisks (*). You can check whether ROS returns parameter values when you create a stack or view a stack.

Confirm

No

Specifies whether to enter the value of a parameter for a second time if the NoEcho property of the parameter is set to true. Default value: false.

Note

You can set the Confirm property to true only when the Confirm property is used for a String-type parameter and the NoEcho property of the parameter is set to true.

Description

A string that describes a parameter. Valid values:

  • zh-cn: describes a parameter in Chinese.

  • en: describes a parameter in English.

Note

The description of the specified language is displayed only based on the language in the console.

ConstraintDescription

No

A string that explains the constraint of a parameter when the constraint is violated.

Label

No

The alias of a parameter. The alias is encoded in UTF-8. When web forms are generated based on templates, the value of Label can be mapped to parameter names.

AssociationProperty

No

A property of Parameters. This property is used to automatically verify the validity of values of a parameter and provide a set of valid values for the parameter.

For more information about the AssociationProperty values supported by ROS and the examples, see AssociationProperty and AssociationPropertyMetadata.

AssociationPropertyMetadata

No

A metadata map that specifies the constraint of AssociationProperty and is used to filter matched items.

This property is of the Map type. For more information about the correspondence between AssociationProperty and AssociationPropertyMetadata and the examples, see AssociationProperty and AssociationPropertyMetadata.

TextArea

No

Specifies whether a parameter supports line breaks. Valid values:

  • true

  • false (default)

In the following example, the Content parameter supports line breaks:

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  Content:
    Type: String
    TextArea: true
Outputs:
  TestContent:
    Value:
      Ref: Content

Required

No

Specifies whether a parameter is required. Valid values:

  • true: A parameter is required and cannot be left empty.

  • false: A parameter is optional.

In the following example, the ECSInstanceId parameter is required.

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  CreateNewECS:
    Type: Boolean
    Label: Whether to Create New Instance
    Default: false
  ECSInstanceId:
    Type: String
    Required: true  # Use Required to specify whether the parameter is required (frontend effect).
    Default: Null
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Equals:
            - ${CreateNewECS}
            - false
Note

The Required property affects only the display effect of the parameter on the front end but does not affect the verification for the parameter.

Placeholder

No

The custom hint displayed in a field for a parameter.

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  Placeholder:
    Type: String
    Placeholder:
      en: Placeholder

Example: Create a stack to create a web application

For example, you want to create a stack to create a web application. The stack contains one Server Load Balancer (SLB) instance, two Elastic Compute Service (ECS) instances, and one ApsaraDB RDS instance. If the web application is under heavy workloads, you can use ECS instances of advanced instance types when you create the stack. If the web application is under regular workloads, you can use ECS instances of basic instance types when you create the stack. The following sample code provides an example on how to define properties for the InstanceType parameter in a template:

Parameters:
  InstanceType:
    Type: String
    AllowedValues:
      - ecs.t1.small
      - ecs.s1.medium
      - ecs.m1.medium
      - ecs.c1.large
    Default: ecs.t1.small
    Label: ECS Instance Type
    Description: Select an instance type. Default value: ecs.t1.small. Valid values: ecs.t1.small, ecs.s1.medium, ecs.m1.medium, and ecs.c1.large.

If you use the preceding sample code to define properties for the InstanceType parameter, you can select a different value from a set of valid values for the InstanceType parameter each time you create a stack based on the template. If you leave the InstanceType parameter empty, the default value ecs.t1.small is used.

The following sample code provides an example on how to reference the InstanceType parameter when you define a resource:

Webserver:
  Type: ALIYUN::ECS::Instance
  InstanceType:
    Ref: InstanceType