【发布时间】:2019-01-04 18:52:53
【问题描述】:
解决方案:不要使用 yml。
我正在尝试传递包含数据库名称和数据库密码的参数以及我的aws cloudformation stack-create 命令。我返回了一个没有多大意义的错误。
Value of property MasterUsername must be of type String
现在,要知道的一件事是我拥有控制台访问权限,因此我可以从字面上看到密码和用户名在控制台中按照设置返回。在我看来,它们都像字符串。
YAML 版本
我在这样的模板中定义堆栈:
Parameters:
DBUser:
Description: db user
Type: String
MinLength: '4'
MaxLength: '16'
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
ConstraintDescription: some description
DBPass:
Description: db password
Type: String
MinLength: '8'
MaxLength: '36'
AllowedPattern: '[a-zA-Z0-9]*'
ConstraintDescription: must contain only alphanumeric characters
Resources:
AppNode:
(...)
DatabaseInstance:
Type: AWS::RDS::DBInstance
Properties:
DBName: app
DBInstanceClass: db.t2.micro
Engine: postgres
EngineVersion: 10
MasterUsername:
- !Ref DBUser
MasterUserPassword:
- !Ref DBPass
DatabaseSG:
Type: AWS::RDS::DBSecurityGroup
Properties:
GroupDescription: Security Group for RDS public access
DBSecurityGroupIngress:
- CIDRIP: 0.0.0.0/0
在我的.env 文件中,我有这个:
[
{
"ParameterKey": "DBUser",
"ParameterValue": "root"
},
{
"ParameterKey": "DBPass",
"ParameterValue": "mydbpassword"
}
]
我运行这个命令:
aws cloudformation create-stack --stack-name app --template-body file://$PWD/stack.json --region us-west-2 --parameters file://$PWD/.env.json
文件类型。
所以首先想到的是它可能将这些值设置为空白。但事实并非如此,因为如果我根本不传递模板或参数,则会引发不同的错误。
An error occurred (ValidationError) when calling the CreateStack operation: Parameters: [DBUser, DBPass] must have values
AWS 是否重新定义了字符串是什么或这里发生了什么?
【问题讨论】:
-
您能否展示您使用的实际 Json 堆栈,因为您没有在 YML 中执行此命令?
标签: amazon-web-services amazon-cloudformation devops