The Parameters section improves the flexibility and reusability of a template. When you create a stack, you can replace the parameter values in the template based on your business requirements.
Syntax
Each parameter consists of a name and several properties. The parameter name can contain only letters and digits and must be unique within the template. You can use the Label field to define the alias of a parameter.
The following table describes the parameter properties.
Property | Required | Description |
---|---|---|
Type | Yes |
The data type of the parameter. Valid values:
Note The
ALIYUN::OOS::Parameter::Value and ALIYUN::OOS::SecretParameter::Value parameter types cannot be verified by using the AllowedPattern property.
|
Default | No | The default value of the 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 in the template. If a default value is found, ROS uses the default
value. Otherwise, an error is returned.
Note The default value can be set to
null , which indicates that this parameter is left empty, and parameter verification is
skipped.
|
AllowedValues | No | The list of valid parameter values. |
AllowedPattern | No | The regular expression that is used to check whether the specified parameter value
is a string. If the input is not a string, an error is returned.
If you use the following special characters, add two backslashes (\\) immediately before the characters that you want to escape:
Note A hyphen (-) that is used as the first or last character in the range does not need
to be escaped. Example: [a-z-].
|
MaxLength | No | The integer value that determines the maximum length of String-type parameters. |
MinLength | No | The integer value that determines the minimum length of String-type parameters. |
MaxValue | No | The numeric value that determines the maximum value that is allowed for a Number-type parameter. |
MinValue | No | The numeric value that determines the minimum value that is allowed for a Number-type parameter. |
NoEcho | No | Specifies whether to mask the parameter value when the GetStack operation is called.
If you set this parameter property to true , only asterisks (*) are returned.
|
Description | No | The string that describes the parameter. |
ConstraintDescription | No | The string that explains the constraint of the parameter. |
Label | No | The alias of the parameter. The alias is encoded in UTF-8. When you create a web form
based on a template, the value of the label field can be mapped to the parameter name.
|
AssociationProperty | No | The associated resource property. If you specify this parameter property, ROS verifies
whether the specified parameter value is valid and provides a list of valid values
based on the associated resource property.
For more information about the values of AssociationProperty that are supported by ROS and examples, see . |
AssociationPropertyMetadata | No | The metadata map that explains the constraint of AssociationProperty.
This property is of the Map type. For more information about the values of AssociationPropertyMetadata that correspond to the values of AssociationProperty and examples, see AssociationProperty and AssociationPropertyMetadata. |
Confirm | No | Specifies whether to enter the parameter value for a second time if NoEcho is set to true . Default value: false .
Note Confirm can be set to
true only if it is used with a String-type parameter and NoEcho is set to true .
|
TextArea | No | Specifies whether the parameter supports line breaks. Default value: false. Valid
values:
In the following example, the Content parameter supports line breaks.
|
Example: Create a stack in a web application
For example, you want to create a stack in a web application, and the stack needs to contain one Server Load Balancer (SLB) instance, two Elastic Compute Service (ECS) instances, and one ApsaraDB RDS instance. If the web application is under heavy workload, you can select an ECS instance that has advanced specifications when you create the stack. Otherwise, you can select an ECS instance that has basic specifications. The following example shows how to specify the InstanceType parameter for an ECS instance:
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: The type of the ECS instance that you want to create. Default value: ecs.t1.small. Valid values: ecs.t1.small, ecs.s1.medium, ecs.m1.medium, and ecs.c1.large.
You can specify the InstanceType parameter each time you create a stack based on the template. If you do not specify
a value for the parameter, the default value ecs.t1.small
is used.
The following example shows how to reference the InstanceType parameter when you define a resource:
Webserver:
Type: ALIYUN::ECS::Instance
InstanceType:
Ref: InstanceType