我尝试通过CloudFormation部署Amazon EC2实例,并尝试使用带有cfn-init的bash脚本克隆存储库。
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#! /bin/bash -xe\n",
"yum install -y aws-cfn-bootstrap\n",
"/opt/aws/bin/cfn-init -v ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource DocumentationInstance ",
" --configsets Install ",
" --region ", { "Ref" : "AWS::Region" }, "\n",
"git clone https://", { "Ref": "GitLabUsn" },"@gitlab.com/user/repository.git \n", { "Ref": "GitLabPwd" }
]]}}
}
但是,当我部署EC2实例时,我可以从cloud-init-output.log
看到git clone失败,这就是错误:
fatal: could not read Password for 'https://username@gitlab.com': No such device or address
如何正确输入bash脚本的密码?我已经尝试yes
找到了here
答案 0 :(得分:1)
添加这样的密码(您也可以将其设置为参数)
Impl
在您的情况下,它将是:
git clone https://user:password@gitlab.com/....git