云形成复杂参数文件



如何使用组名设置复杂的参数 json 文件,我稍后可以在堆栈文件中将其引用为 !参考数据库管理员?

这是我的参数.json文件的示例:

[
{
"ParameterKey": "DBName",
"ParameterValue": {
"Default": "test",
"Description": "The database name",
"Type": "String",
"MinLength": "1",
"MaxLength": "64",
"AllowedPattern": "[a-zA-Z][a-zA-Z0-9]*",
"ConstraintDescription": "must begin with a letter and contain only alphanumeric characters."
}
},
{
"ParameterKey": "DBUser",
"ParameterValue" : {
"NoEcho": "true",
"Default": "test",
"Description": "The database admin account username",
"Type": "String",
"MinLength": "1",
"MaxLength": "16",
"AllowedPattern": "[a-zA-Z][a-zA-Z0-9]*",
"ConstraintDescription": "must begin with a letter and contain only alphanumeric characters."
}
}

]

我收到这样的错误:

Parameter validation failed:
Unknown parameter in Parameters[0]: "Label", must be one of: ParameterKey, ParameterValue, UsePreviousValue, ResolvedValue

我认为您混淆了两个不同的文件。

CloudFormation 模板用于定义参数、资源和输出。parameters部分如下所示:

"VPCCIDR": {
"Description": "CIDR Block for VPC",
"Type": "String",
"Default": "10.0.0.0/16",
"AllowedValues": [
"10.0.0.0/16"
]
},

定义包括参数类型、默认值等。

然后是可用于传入模板中定义的参数的值的参数文件。此文件定义参数本身,而是提供参数的值列表,而不必在命令行上指定它们。

它看起来像:

[
{
"ParameterKey": "string",
"ParameterValue": "string",
"UsePreviousValue": true|false,
"ResolvedValue": "string"
}
...
]

从您的问题来看,我认为您应该使用第一种类型的文件,它定义了应该部署在 CloudFormation 堆栈中的所有资源,而您的代码(上面(正在尝试将这些字段转换为第二种类型的文件的格式。

请参阅: 示例模板 - AWS CloudFormation

最新更新