AWS CloudFormation
User Guide (API Version 2010-05-15)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...


AWS CloudFormation parameters are values that you define in the template Parameters section. A parameter can have a default value. The default value is overridden if you specify a value for the parameter as part of the aws cloudformation create-stack --parameters option. Parameter values you override at runtime are returned as part of the aws cloudformation describe-stacks command, unless you suppress that in the parameter declaration by including the NoEcho property with a value of true. If you provide the NoEcho property, the parameter value is displayed as asterisks (*****). (Parameter values you do not override are not displayed.)

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.

For the String type, you can define the following constraints: MinLength, MaxLength, Default, AllowedValues, and AllowedPattern.

For the Number type, you can define the following constraints: MinValue, MaxValue, Default, and AllowedValues. A number can be an integer or a float value.

For more information about parameter constraints, see Parameters Declaration.

Note that all parameter values are specified as strings in the template JSON. This means Number parameter values must also be surrounded by quotes. For example, the Default value for MyNumber specifies a number and it is surrounded by quotes.

"Parameters" : {
    "MyNumber" : {
      "Type" : "Number",
      "Default" : "10",
      "MinValue" : "1"

Parameters can be dereferenced in the Resources and Outputs section, so you can use any parameter you declare as a value for a resource, resource property, reference, function, or output value.

The following example shows the declaration of the InstanceType parameter, a String type that allows only the enumerated values t1.micro, m1.small, and m1.large with a default of m1.small.

"Parameters" : {
    "InstanceType" : {
      "Type" : "String",
      "Default" : "t1.micro",
      "AllowedValues" : ["t1.micro", "m1.small", "m1.large"],
      "Description" : "Enter t1.micro, m1.small, or m1.large. Default is t1.micro."

If you wanted to override this value at the command line, your command might resemble the following:

aws cloudformation create-stack --stack-name TestStack --template-body file:///home/local/MyTemplate.template --parameters ParameterKey=InstanceType,ParameterValue=m1.large

If you have more than one parameter, separate the param-value pairs with a space. For example, the assume the MyTemplate.template requires two parameters. You could create a stack based on that template using a command similar to the following:

aws cloudformation create-stack --stack-name TestStack --template-body file:///home/local/MyTemplate.template --parameters ParameterKey=MyName,ParameterValue=Joe ParameterKey=MyValue,ParameterValue=10

Note that in this case if you mistype the parameter name, AWS CloudFormation will not create the stack. It will report that the template doesn't contain the parameter.

Most of the sample templates declare a Parameters section (see Example Templates). Also, for technical details about the Parameters section format, see Parameters Declaration.