【发布时间】:2018-05-21 16:35:25
【问题描述】:
通过添加一些 cfn-init 来从 S3 存储桶请求数据。 我相信我从 powershell 调用 cfn-init.exe 时遇到了语法问题,但似乎找不到在哪里。此结构取自Bootstrapping AWS CloudFormation Windows Stacks AWS Example。我还尝试从 AWS cfn-init documentation 的 bash 结构进行调整,但没有成功。
"UserData": {"Fn::Base64": {"Fn::Join": ["\n", [
"<powershell>",
...
"cfn-init.exe -v -s", { "Ref" : "AWS::StackName" },
" -r EC2Instance",
"</powershell>"
"Metadata" : {
"AWS::CloudFormation::Init" : {
"config": {
"files" : {
"C:\\chef\\validator.pem" : {
"source" : "https://s3.amazonaws.com/dtcfstorage/validator.pem",
"authentication" : "s3creds"
}
}
},
"AWS::CloudFormation::Authentication" : {
"s3creds" : {
"type" : "S3",
"roleName" : "awss3chefkeyaccess"
}
}
}
}
cfn-init.exe 正在运行,但在参数传递到新行时出错:
2018/05/21 15:35:08Z:消息:来自用户脚本的错误:用法:cfn-init.exe [选项] 或:cfn-init.exe [选项] 或: 猫 | cfn-init.exe [选项] -
cfn-init.exe:错误:-s 选项需要一个参数 cloudinittest :术语“cloudinittest”未被识别为 cmdlet、函数、脚本文件或可操作的名称 程序。检查名称的拼写,或者如果包含路径,请验证路径是否正确并重试。 在 C:\Windows\TEMP\UserScript.ps1:30 char:1 + 云初始化测试 + ~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (cloudinittest:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
-r :术语“-r”未被识别为 cmdlet、函数、脚本文件或可运行程序的名称。检查 名称的拼写,或者如果包含路径,请验证路径是否正确并重试。 在 C:\Windows\TEMP\UserScript.ps1:31 char:2 + -r EC2Instance + ~~ + CategoryInfo : ObjectNotFound: (-r:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
【问题讨论】:
-
还应该在来自 AWS 的 Windows Server 2016 基础 AMI 上添加它。我还在 AWS 的 2012 R2 AMI 上尝试了相同的代码,结果相似。
标签: amazon-web-services amazon-cloudformation