gpt4 book ai didi

amazon-web-services - 为什么我的 CloudFormation 脚本无法下载文件?

转载 作者:行者123 更新时间:2023-12-03 07:14:58 25 4
gpt4 key购买 nike

我需要在 Windows 实例初始化期间下载文件。为了测试这一点,我使用以下脚本下载 Google Logo (使用 Windows Roles and Features template 的简化版本):

{
"AWSTemplateFormatVersion" : "2010-09-09",

"Description" : "Test download.",

"Resources" : {

"InstanceSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable RDP",
"SecurityGroupIngress" : [
{"IpProtocol" : "tcp", "FromPort" : "3389", "ToPort" : "3389", "CidrIp" : "0.0.0.0/0"}
]
}
},

"WindowsServer": {
"Type" : "AWS::EC2::Instance",
"Metadata" : {
"AWS::CloudFormation::Init" : {
"config" : {
"files" : {
"c:\\test\\google-logo.png" : {
"source" : "http://www.google.com/images/srpr/logo4w.png"
}
}
}
}
},

"Properties": {
"InstanceType" : "m1.small",
"ImageId" : "ami-bbf2e1cf",
"SecurityGroups" : [ {"Ref" : "InstanceSecurityGroup"} ],
"KeyName" : "POP",
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"<script>\n",

"cfn-init.exe -v -s ", { "Ref" : "AWS::StackId" },
" -r WindowsServer",
" --region ", { "Ref" : "AWS::Region" }, "\n",

"</script>"
]]}}
}
},

"WindowsServerWaitHandle" : {
"Type" : "AWS::CloudFormation::WaitConditionHandle"
},

"WindowsServerWaitCondition" : {
"Type" : "AWS::CloudFormation::WaitCondition",
"DependsOn" : "WindowsServer",
"Properties" : {
"Handle" : {"Ref" : "WindowsServerWaitHandle"},
"Timeout" : "1800"
}
}
}
}

这将完成执行,没有错误......并且没有文件。我哪里出错了?

最佳答案

乔纳森

我尝试了您的模板,并且文件已成功下载。您可以检查实例上的 cfn 日志。它们位于 c:\cfn\log\ 中。我的 cfn-init.log 显示:

2013-07-19 21:30:18,269 [DEBUG] Parent directory c:\test does not exist, creating
2013-07-19 21:30:18,269 [DEBUG] Writing content to c:\test\google-logo.png
2013-07-19 21:30:18,269 [DEBUG] Retrieving contents from http://www.google.com/images/srpr/logo4w.png
2013-07-19 21:30:18,316 [DEBUG] No mode specified for c:\test\google-logo.png
2013-07-19 21:30:18,316 [WARNING] Unsupported OS for setting owner/group: nt

我的 cfn-wire.log 显示:

2013-07-19 21:30:18,269 [DEBUG] Request: GET http://www.google.com/images/srpr/logo4w.png [headers: {'Accept-Encoding': 'identity, deflate, compress, gzip', 'Accept': '*/*', 'User-Agent': 'python-requests/0.11.1'}]
2013-07-19 21:30:18,302 [DEBUG] Response: 200 http://www.google.com/images/srpr/logo4w.png [headers: {'content-length': '18946', 'x-xss-protection': '1; mode=block', 'x-content-type-options': 'nosniff', 'expires': 'Fri, 19 Jul 2013 21:30:20 GMT', 'server': 'sffe', 'last-modified': 'Mon, 25 Mar 2013 19:02:15 GMT', 'cache-control': 'private, max-age=31536000', 'date': 'Fri, 19 Jul 2013 21:30:20 GMT', 'content-type': 'image/png'}]

关于amazon-web-services - 为什么我的 CloudFormation 脚本无法下载文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17750232/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com