为什么我的CloudFormation脚本下载文件? [英] Why won't my CloudFormation script download a file?
问题描述
我需要我的Windows实例的初始化过程中下载的文件。为了验证这一点,我用下面的脚本下载谷歌徽标(使用的<一个简化版本href="https://s3.amazonaws.com/cloudformation-templates-us-east-1/Windows_Roles_And_Features.template"相对=nofollow> Windows角色和功能模板):
I need to download a file during the initialisation of my Windows instance. To test this, I'm using the following script to download the Google logo (using a simplified version of the 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"
}
}
}
}
此完成,没有错误...,没有文件执行。我在哪里去了?
This finishes executing with no error... and no file. Where am I going wrong?
推荐答案
乔纳森,
我想你的模板和文件下载成功对我来说。您可以检查实例上的CFN日志。他们在 C:\ CFN \登录\
。我的CFN-init.log显示:
I tried your template and the file downloaded successfully for me. You can check the cfn logs on the instance. They are in c:\cfn\log\
. My cfn-init.log shows:
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显示:
And my cfn-wire.log shows:
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'}]
这篇关于为什么我的CloudFormation脚本下载文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!