CloudFormation 参数模板错误:参数不是字母数字

Dip*_*shi 13 parameters amazon-web-services aws-cloudformation

我在用

aws cloudformation validate-template --template-body file://template.json
Run Code Online (Sandbox Code Playgroud)

然后面对“CloudFormation Parameter Template Error : Parameter is non alphanumeric”错误,以下代码显示了我的params.jsontemplate.json文件。

参数文件

[
    {
        "ParameterKey": "name_for_abc",
        "ParameterValue": "abc"
    }
]
Run Code Online (Sandbox Code Playgroud)

模板文件

{
    "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"
                        }
                    }
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Dip*_*shi 20

要解决此问题,参数重新命名name_of_abc,以nameofabcparams.json文件和Parameters的CloudFormation模板的部分。

AWS 文档

必须为每个参数指定一个逻辑名称(也称为逻辑 ID),该名称必须是字母数字且在模板内的所有逻辑名称中是唯一的。