Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CloudFormation Parameter Template Error : Parameter is non alphanumeric

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"
                        }
                    }
                }
            }
        }
    }
}
like image 774
Dipika Joshi Avatar asked Dec 05 '18 06:12

Dipika Joshi


People also ask

How do you reference a parameter in CloudFormation?

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.

What is parameter validation error?

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.

What are parameters which are predefined by CloudFormation called?

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.

What is AWS :: NoValue?

Example YAML The AWS::NoValue pseudo parameter removes the corresponding resource property when it's used as a return value.

What is a CloudFormation parameter?

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.

How many parameters can I have in an AWS CloudFormation template?

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.

Why does the CloudFormation template validator reject the bucket resource?

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" } } }

What is a validation error in AWS CloudFormation?

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.


1 Answers

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.

like image 134
Dipika Joshi Avatar answered Sep 18 '22 05:09

Dipika Joshi