| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
You can configure your templates to require input parameters by adding them to the Parameters section. Each parameter you add must contain a value at runtime. You can specify a default value for each parameter to make the parameter an option. If you do not specify a default value, you must provide a value for that parameter when you create the stack.
A parameter can be declared as a String, Number, or
CommaDelimitedList type. The String and
Number types can have constraints that AWS CloudFormation uses to validate the value of the
parameter. For more information about parameter constraints, see Parameters Declaration.
The following sample configures a single parameter, Email:
"Parameters" : {
"Email" : {
"Type" : "String"
}
}The parameter has no default, so you must provide a value to create the stack. After you create the
CloudWatch Alarms stack with a value for Email, the cfn-describe-stacks
command returns the following:
STACK myAlarms
arn:aws:cfn:us-east-1:165024647323:stack/f5b4cbb0-24d7-11e0-93a-508be05d086/myAlarms
Email=Joe@Joe.com 2011-01-20T20:57:57Z CREATE_COMPLETE
User Initiated false Instance=i-0723826bYou can configure the parameter to not display with the NoEcho parameter:
"Parameters" : {
"Email" : {
"Type" : "String",
"NoEcho" : "TRUE"
}
}Here's the output from a stack created with the same template, but with the NoEcho
set to TRUE:
STACK myAlarms2
arn:aws:cfn:us-east-1:165024647323:stack/ff6ff540-24db-11e0-94f8-5081b017c4b/myAlarms2
Email=****** 2011-01-20T21:26:52Z CREATE_COMPLETE User Initiated
false Instance=i-f734959bThe value for Email is masked with asterisks.
To supply the values for parameters, you include the --parameters option to the
cfn-create-stack command.
For example, the following command adds a value for the UserName and
Password parameters:
PROMPT> cfn-create-stack MyStack -f My.Template --parameters "UserName=Joe;Password=JoesPw"Parameters are separated with semicolons. Note that parameter names are case sensitive. If you mistype the
parameter name when you run cfn-create-stack, AWS CloudFormation will not create the stack, and will report
that the template doesn't contain the parameter.