The Parameters section of a template defines input values that users specify at stack creation time, making templates flexible and reusable.
Syntax
Each parameter has a name and a set of properties. Parameter names can contain only letters and digits and must be unique within a template. Use the Label property to define an alias.
The following table describes the supported properties.
|
Property |
Required |
Description |
|
Type |
Yes |
The parameter data type. Valid values:
Note
AllowedPattern does not support the |
|
Default |
No |
The default value of a parameter. If no value is specified at stack creation, ROS uses this default. If no default is defined, an error is reported. Note
If the default is set to |
|
AllowedValues |
No |
The valid values of a parameter. |
|
AllowedPattern |
No |
A regular expression for validating String-type parameters. Applying this property to non-String parameters causes an error. Prepend two backslashes (\\) before each of the following special characters:
Note
A hyphen (-) used as the first or last character in a range does not need escaping. Example: [a-z-]. |
|
MaxLength |
No |
Maximum number of characters allowed for a String-type parameter. |
|
MinLength |
No |
Minimum number of characters required for a String-type parameter. |
|
MaxValue |
No |
Maximum numeric value allowed for a Number-type parameter. |
|
MinValue |
No |
Minimum numeric value allowed for a Number-type parameter. |
|
NoEcho |
No |
When set to |
|
Confirm |
No |
Requires the parameter value to be entered twice when NoEcho is set to Note
The Confirm property can be set to |
|
Description |
The description of a parameter. Supports localized values:
Note
The console displays the description that matches the current language setting. |
|
|
ConstraintDescription |
No |
The error message displayed when a parameter constraint is violated. |
|
Label |
No |
A UTF-8 encoded alias for the parameter. In template-based web forms, |
|
AssociationProperty |
No |
Automatically validates parameter values and provides a list of valid options. For more information about the AssociationProperty values supported by ROS and the examples, see AssociationProperty and AssociationPropertyMetadata. |
|
AssociationPropertyMetadata |
No |
A map that constrains AssociationProperty and filters 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 |
Whether the parameter supports line breaks. Valid values:
In the following example, the Content parameter supports line breaks:
|
|
Required |
No |
Whether the parameter is required. Valid values:
In the following example, the ECSInstanceId parameter is required.
Note
The Required property affects only the frontend display and does not enforce backend validation. |
|
Placeholder |
No |
A hint displayed in the input field for a parameter.
|
Example: Define the InstanceType parameter
Suppose you create a stack for a web application that contains one SLB instance, two ECS instances, and one ApsaraDB RDS instance. You can choose different ECS instance types based on workload requirements. The following code defines 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.
With this definition, you can select a different InstanceType value each time you create a stack. If the InstanceType parameter is omitted, the default ecs.t1.small is used.
The following code references the InstanceType parameter in a resource definition:
Webserver:
Type: ALIYUN::ECS::Instance
InstanceType:
Ref: InstanceType