All Products
Search
Document Center

Parameter

Last Updated: Dec 20, 2019

When creating and executing a template, you can use parameters to improve the flexibility and reusability of the template.

Definition

You can define a parameter in the Parameters field of the template, including the parameter name, description, type, default value, and verification rules.

Syntax

  • YAML format
  1. Parameters:
  2. Parameter-name-1: # The name of the parameter. The name can contain lowercase letters, uppercase letters, digits, underscores (_), and hyphens (-). Spaces are not allowed. We recommend that you use the lower camel case for a name. Example: instanceId.
  3. Type: String # Optional. The type of the parameter. Valid values: List, Number, String, Boolean, and Json. Default value: String.
  4. Description: description # Optional. The description of the parameter, such as the features of the parameter.
  5. Default: default-value # Optional. The default value of the parameter.
  6. AllowedValues: # Optional. The list of the valid values for the parameter.
  7. - value1
  8. - value2
  9. AllowedPattern: regular-expression # Optional. The regular expression that must be matched with the parameter value. This attribute is valid only when the parameter value is a string.
  10. MinLength: 1 # Optional. The minimum length of the parameter value. This attribute is valid only when the parameter value is a string.
  11. MaxLength: 10 # Optional. The maximum length of the parameter value. This attribute is valid only when the parameter value is a string.
  • JSON format (For more information, see the parameter description for the YAML format.)
  1. {
  2. "Parameters": {
  3. "parameter-name-1": {
  4. "Type": "String",
  5. "Description": "description",
  6. "Default": "default-value",
  7. "AllowedValues": [
  8. "value1",
  9. "value2"
  10. ],
  11. "AllowedPattern": "regular-expression",
  12. "MinLength": 1,
  13. "MaxLength": 10
  14. }
  15. }
  16. }

Reference

You can reference the parameters defined above as attributes in the Tasks field. The following is the syntax for referencing parameters:

  1. "some text {{ parameter_name }} some text {{parameter_name_2}} ..."

For example:

When the YAML format is used, referenced parameters must be enclosed in the double quotation marks (“).

  1. "{parameter-name}" # Reference a parameter itself.
  2. "this is the {parameter-name}" # Reference a parameter in a fixed string.
  3. "hello {{ parameter-last-name }} {{ parameter-first-name }}" # Reference multiple parameters in a fixed string.

Pseudo parameters

OOS provides pseudo parameters for obtaining the execution information. You can reference these parameters without the need to define them. The following table describes the supported pseudo parameters. If you need more pseudo parameters, submit a ticket and describe your scenarios. We will give you feedback and support as soon as possible.

Name Type Description Example
ACS::TemplateName String The name of the template that is executed. ACS-ECS-StartInstances br or MyTemplate1
ACS::ExecutionId String The ID of the execution. exec-21234455677892ac
ACS::Region String The region where the template is executed. cn-hangzhou
ACS::AccountId String The account that is used to execute the template. 12345678901234