| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
If present, the optional Parameters section of an AWS CloudFormation template must declare at least one parameter.
The optional Parameters section enables you to pass values into your template at stack creation time. Parameters let you create templates that can be customized for each stack deployment. When you create a stack from a template containing parameters, you can specify values for those parameters. Within the template, you can use the "Ref" intrinsic function to specify those parameter values in properties values for resources. For example, you can define a string parameter with the following Parameters section:
"Parameters" : {
"URL" : {
"Type" : "String"
}
}Note
If present, the Parameters section must declare at least one parameter. There can be a maximum of 50 parameters in an AWS CloudFormation template.
At runtime, you can use the --parameters option of
cfn-create-stack to set the URL parameter to a specific value:
cfn-create-stack MyStack --template-file My.template --parameters "URL=127.0.0.1"
Multiple parameter assignments are separated with a semicolon.
Note
By default, cfn-describe-stacks returns parameter values. To prevent sensitive
parameter values such as passwords from being returned, include a
NoEcho property set to true.
Parameters can have rules, called constraints, that determine valid values for a parameter. These constraint properties you validate the template user's input before any resources are created. For example, you can have a constraint that a string include only alphanumeric characters or that a numeric parameter fall between 1 and 10.
The Parameters section is composed of the key name Parameters,
followed by a single colon. Braces enclose all parameter declarations. Parameters
declared within the Parameters section are delimited by a comma.
Each parameter must declare a double-quoted name, followed by a colon. Parameter names must be alphanumeric and unique among all logical names within a template.
A parameter can be declared as one of following types:
String, Number, or
CommaDelimitedList. For a parameter that has a
String or Number type, you can define
constraints that AWS CloudFormation uses to validate the value of the parameter.
Parameters have the following properties:
| Property | Required | Description |
|---|---|---|
|
Type |
Yes |
String, Number, or CommaDelimitedList. A parameter of type A parameter of type A parameter of type |
|
Default |
No |
A value of the appropriate type for the template to use if no value is specified at stack creation. If the parameter has constraints defined, this value must adhere to those constraints. |
|
NoEcho |
No |
If |
|
AllowedValues |
No |
An array containing the list of values allowed for the parameter. |
|
AllowedPattern |
No |
|
|
MaxLength |
No |
|
|
MinLength |
No |
|
|
MaxValue |
No |
|
|
MinValue |
No |
|
|
Description |
No |
A String type up to 4000 characters describing the parameter. |
|
ConstraintDescription |
No |
A String type explaining the constraint requirements that appears when the constraint is violated. For example, a parameter that has an AllowedPattern of "[A-Za-z0-9]+" would display this error message when the user specified an invalid value: cfn-create-stack: Malformed input-Parameter MyParameter must match pattern [A-Za-z0-9]+ By adding a ConstraintDescription with a value "must only contain upper- and lowercase letters, and numbers", you can display a customized error message: cfn-create-stack: Malformed input-Parameter MyParameter must only contain upper and lower case letters and numbers |
The following example Parameters section declares two
parameters. The DBPort parameter is of type Number with a default of 3306
and a minimum value of 1150 and maximum value 65535. The DBPwd parameter is of type
String with no default value, NoEcho is set to
true to prevent cfn-describe-stacks from returning the parameter value, minimum length
of 1, maximum length of 41, and pattern that allows lowercase and uppercase alphabetic
characters and numerals. The UserRoles parameter is a CommaDelimitedList
with a default list containing the string values guest and newhire.
"Parameters" : {
"DBPort": {
"Default": "3306",
"Description" : "TCP/IP port for the database",
"Type": "Number",
"MinValue": "1150",
"MaxValue": "65535"
},
"DBPwd": {
"NoEcho": "true",
"Description" : "The database admin account password",
"Type": "String",
"MinLength": "1",
"MaxLength": "41",
"AllowedPattern" : "[a-zA-Z0-9]*"
},
"UserRoles" : {
"Type" : "CommaDelimitedList",
"Default" : "guest,newhire",
"NoEcho" : "TRUE"
}
}