Amazon web services 如何添加密码参数字段而不通过cloudformation显示值?
当我创建cloudformation堆栈时,我将接受一些输入。Cloudformation stack将创建一个SSM文档(AWS systems manager),我想在执行之前将密码作为SSM文档的输入参数Amazon web services 如何添加密码参数字段而不通过cloudformation显示值?,amazon-web-services,amazon-cloudformation,ssm,aws-systems-manager,Amazon Web Services,Amazon Cloudformation,Ssm,Aws Systems Manager,当我创建cloudformation堆栈时,我将接受一些输入。Cloudformation stack将创建一个SSM文档(AWS systems manager),我想在执行之前将密码作为SSM文档的输入参数 "parameters": { "sourceAMIid": { "type": "String", "description": "Source/Base AMI to be used for gene
"parameters": {
"sourceAMIid": {
"type": "String",
"description": "Source/Base AMI to be used for generating your Automated AMI",
"default": { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "HVM64"]}
},
"Username": {
"type": "String",
"description": "account username/email",
"default": "none"
},
"password": {
"type": "String",
"description": "account password",
"default": "none"
},
"productName": {
"type": "String",
"description": "The syntax of this parameter is ProductName-ProductVersion.",
"default": {
"Ref": "productName"
}
}
}
当我在该字段中输入密码时,它将按原样显示确切的单词。是否有任何方法可以定义密码参数以显示如下
是的,您可以使用云形成模板屏蔽密码。您只需在如下所示的内部参数中将“NoEcho”设置为“true”。有关详细信息,请参阅和使用带有NoEcho的输入参数获取凭据
"Parameters" : {
"DBPort" : {
"Default" : "3306",
"Description" : "TCP/IP port for the database",
"Type" : "Number",
"MinValue" : "1150",
"MaxValue" : "65535"
},
"DBPwd" : {
"NoEcho" : "true",
"Description" : "The database admin account password",
"Type" : "String",
"MinLength" : "1",
"MaxLength" : "41",
"AllowedPattern" : "^[a-zA-Z0-9]*$"
}
}
使用终端,这可以通过使用
bash
和read-s-p
来实现
在下面的示例中,我有一个Makefile,它读取密码,但不向终端回显输入
Make命令
make create-test
Makefile
create-test: s3 delete-test
@read -s -p "Enter DB Root Password: " pswd; \
aws cloudformation create-stack --stack-name test --template-body file://master.yaml --parameters ParameterKey=DBRootPassword,ParameterValue=$$pswd
由于我是在SSM文档代码下使用它的,所以我以前也尝试过这个,它在创建cloudformation堆栈时给了我错误:{“类型”:“AWS::SSM::Document”,“属性”:{“DocumentType”:“Automation”,“Content”:{“schemaVersion”:“0.3”,“parameters”:{“password”:{“Type”:“String”,“NoEcho”:“true”,“description:“account password”,“default:“none”},我得到了这个错误未知属性“noEcho”。(服务:amazonsm;状态代码:400;错误代码:InvalidDocumentContent;请求ID:3b856651-1194-4e3f-8bc5-bf88a9b9734d)未知属性“noEcho”。(服务:AmazonSM;状态代码:400;错误代码:InvalidDocumentContent;请求ID:3b856651-1194-4e3f-8bc5-bf88a9b9734d)将
“NoEcho”
放在参数上,而不是放在文档上。尝试使用机密管理器。