i am using
aws cloudformation validate-template --template-body file://template.json
and then facing "CloudFormation Parameter Template Error : Parameter is non alphanumeric" error, following code shows my params.json
and template.json
files.
params.json
[
{
"ParameterKey": "name_for_abc",
"ParameterValue": "abc"
}
]
template.json
{
"AWSTemplateFormatVersion": "2010-09-09",
"Transform": "AWS::Serverless-2016-10-31",
"Description": "some text",
"Parameters": {
"name": {
"Description": "name_of_abc",
"Type": "String"
}
},
"Resources": {
"LambdaFunctionAuto": {
"Type": "AWS::Serverless::Function",
"Properties": {
"Environment": {
"Variables": {
"name_of_abc": {
"Ref": "name_of_abc"
}
}
}
}
}
}
}
Referencing a parameter within a template You use the Ref intrinsic function to reference a parameter, and AWS CloudFormation uses the parameter's value to provision the stack. You can reference parameters from the Resources and Outputs sections of the same template.
The error occurs when the value of the child stack that's passed from the parent stack doesn't match the parameter type. The error also occurs when the parameter's resource doesn't exist in the account in that Region.
Pseudo parameters are parameters that are predefined by AWS CloudFormation. You don't declare them in your template. Use them the same way as you would a parameter, as the argument for the Ref function.
Example YAML The AWS::NoValue pseudo parameter removes the corresponding resource property when it's used as a return value.
AWS CloudFormation validates the parameter value as a number; however, when you use the parameter elsewhere in your template (for example, by using the Ref intrinsic function), the parameter value becomes a string. For example, users could specify "8888" . An array of integers or floats that are separated by commas.
You can have a maximum of 200 parameters in an AWS CloudFormation template. Each parameter must be given a logical name (also called logical ID), which must be alphanumeric and unique among all logical names within the template. Each parameter must be assigned a parameter type that is supported by AWS CloudFormation.
The error is caused because the CloudFormation template validator sees the bucket resource as a section-level specification, which isn't allowed as a template property. { "Resources": { "WaitCondition": { "Type": "AWS::CloudFormation::WaitCondition" } }, "Bucket": { "Type": "AWS::S3::Bucket", "Properties": { "Name": "BucketName" } } }
When you create or update stacks and create change sets, AWS CloudFormation uses whatever values exist in Parameter Store at the time the operation is run. If a specified parameter doesn't exist in Parameter Store under the caller's AWS account, AWS CloudFormation returns a validation error.
To fix the problem, rename the parameter name_of_abc
to nameofabc
in the params.json
file and the Parameters
section of the CloudFormation template.
From the AWS documentation:
Each parameter must be given a logical name (also called logical ID), which must be alphanumeric and unique among all logical names within the template.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With