All Products
Search
Document Center

Resource Orchestration Service:Overview

Last Updated:Dec 22, 2023

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 multiple 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 for parameters.

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 set of strings that are separated by commas (,). You can use the Fn::Select function to reference the strings 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). Example: my_image.

  • ALIYUN::OOS::SecretParameter::Value: an encrypted parameter that is stored in OOS Parameter Store. 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 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 to 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

Specifies whether to mask the return value of a parameter when the GetStack operation is called. If you set this property to true, ROS returns the parameter value masked as asterisks (*).

Description

No

A string that describes a parameter.

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

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.

For more information about the correspondence between AssociationProperty and AssociationPropertyMetadata and the examples, see AssociationProperty and AssociationPropertyMetadata.

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.

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: The parameter is required and cannot be left empty.

  • false: The parameter is optional.

In the following example, the ECSInstanceId parameter is required.

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  CreateNewECS:
    Type: Boolean
    Label: Whether to Create A 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 for a parameter.

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

Example: Create a stack for a web application

For example, you want to create a stack for 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 a heavy workload, you can use ECS instances of advanced instance types when you create the stack. If the web application is under a common workload, 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