Parameters

Last Updated: Sep 11, 2017

Parameters are used to overwrite some values in the template when a resource stack is created, which improves flexibility and reusability of the template.

For example, a template can be used to create a Web application containing one Server Load Balancer instance, two ECS instances, and one ApsaraDB for RDS instance. If the Web application has a higher load, the high-end ECS instance can be selected during creation; otherwise, the low-end ECS instance can be selected during creation. In this case, the following parameters can be defined:

  1. "Parameters" : {
  2. "InstanceType" : {
  3. "Type" : "String",
  4. "AllowedValues":["ecs.t1.small","ecs.s1.medium", "ecs.m1.medium", "ecs.c1.large"],
  5. "Default": "ecs.t1.small",
  6. "Label": "ECS instance type".
  7. "Description": "Select the configuration for creating an ECS example, which is ecs.t1.small by default. Options include ecs.t1.small, ecs.s1.medium, ecs.m1.medium, and ecs.c1.large."
  8. }
  9. }

For the InstanceType parameter defined above, you can reassign a value to it when using the template to create a resource stack. If you do not set any parameter value, ecs.t1.small is used by default. This parameter can be referenced when the resource is defined:

  1. "Webserver" : {
  2. "Type" : "ALIYUN::ECS::Instance",
  3. "InstanceType": {
  4. "Ref": "InstanceType"
  5. }
  6. }

Syntax

Each parameter consists of the parameter name and parameter attribute.

The parameter name must consist of letters and numbers and cannot be the same as other parameter names in the same template. The Label field can be used to define a friendly parameter name, which is useful when the template is used to generate a Web form dynamically.

Parameter attribute list:

Attribute Required Description
Type Yes

Data type of the parameter.

String

String. For example: “ecs.s1.medium”.

Number

Integer or floating point number. For example: 3.14.

CommaDelimitedList

A group of strings or numbers separated by commas, whose values can be indexed by using the Fn::Select function. For example: “80, foo, bar”.

Json

A string in the Json format. For example: { “foo”: “bar” }.

Boolean

A Boolean value. For example: TRUE or FALSE.

Default No When creating a resource stack, if you do not transmit the specified value, the orchestration service will check whether a default value is defined in the template. If yes, the default value is used; otherwise, the system reports an error.
AllowedValues No List containing the allowed values of parameters.
AllowedPattern No A regular expression, used to check whether the parameter of an entered string type matches. If the parameter you entered is not of string type, the system reports an error.
MaxLength No An integer, used to determine the maximum number of characters allowed for String type.
MinLength No An integer, used to determine the minimum number of characters allowed for String type.
MaxValue No A numeric value, used to determine the maximum numeric value allowed for Number type.
MinValue No A numeric value, used to determine the minimum numeric value allowed for Number type.
NoEcho No Whether the parameter value is output when stack query is called. If the value is set to “true”, only asterisks (**) will be output.
Description No String used to describe the parameter.
ConstraintDescription No String used to describe the constraint of this parameter when this constraint is violated.
Label No Parameter alias, supporting the UTF-8 character. It can be mapped to label when a Web form is generated through the template.
AssociationProperty No
You can use the parameter AssociationProperty to automatically verify the parameter validity and provide options for the parameter.
Format: “ROS resource type:property”, without spaces.
For example: specify “ALIYUN::ECS::Instance:ImageId”, indicating this parameter will be referenced by the attribute ImageId of ALIYUN::ECS::Instance. Then, the ROS console checks whether that the image ID specified for this parameter is available and lists other options in the drop-down box.
Currently ROS only supports the verification of the image ID parameter.

Example

The statement for the Parameters in the following example has two parameters. The username parameter is of String type, and the default value is “anonymous”. The minimum length that can be specified is 6 characters, the maximum length that can be specified is 12 characters, and the allowed values are anonymous, user-one, and user-two. Note that the default value of username must comply with the length restriction and allowed value restriction. The password parameter is of String type, without any default value. Setting the NoEcho attribute to true can prevent the stack query interface from returning the parameter value. The minimum length that can be specified is 1 characters, and the maximum length that can be specified is 41 characters. This mode supports lowercase and uppercase letters, characters and numbers.

  1. "Parameters" : {
  2. "username" : {
  3. "Label": "User name".
  4. "Description": "Enter the user name".
  5. "Default": "anonymous",
  6. "Type" : "String",
  7. "MinLength" : "6",
  8. "MaxLength" : "12",
  9. "AllowedValues": ["anonymous", "user-one", "user-two"]
  10. },
  11. "password" : {
  12. "Label": "Password".
  13. "NoEcho" : "True",
  14. "Description": "Enter the user password".
  15. "Type" : "String",
  16. "MinLength" : "1",
  17. "MaxLength" : "41",
  18. "AllowedPattern" : "[a-zA-Z0-9]*"
  19. }
  20. }

Pseudo parameters

Pseudo parameters are fixed parameters provided by the ROS orchestration engine. They can be referenced like custom parameters, and their values are determined during the orchestration operation. Currently, the following pseudo parameters are supported:

  • ALIYUN::StackName - Name of the current resource stack.
  • ALIYUN::StackId - ID of the current resource stack.
  • ALIYUN::Region - Region where the current resource stack is.
  • ALIYUN::AccountId - User ID of the current resource stack.
  • ALIYUN::NoValue - Attribute that is deleted when the resource is created or updated.
Thank you! We've received your feedback.