我需要的应用服务器,这是豆茎情况下,要做到在启动时的一些动作,我想运行传递到该实例的属性的UserData这是提供给普通的EC2实例一bash脚本的。
I need the application server, which is beanstalk instances, to do some actions upon startup and I thought of running a bash script passed to the instance with the UserData property which is available to regular EC2 instances.
我已经发现了几个例子CloudFormation模板,这是否与普通EC2实例,但青苗没有例子。我试图把它添加到性能领域的应用:
I've found several example CloudFormation templates which does this with regular EC2 instances, but no example with Beanstalk. I've tried to add this to the properties field for the application:
"MyApp" : {
"Type" : "AWS::ElasticBeanstalk::Application",
"Properties" : {
"Description" : "MyApp description",
"ApplicationVersions" : [{
...
}],
"UserData" : {
"Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash\n",
"touch /tmp/userdata_sucess\n"
]]
}},
...
我也尝试添加到环境的一部分:
I also tried to add to the environment part:
"MyAppEnv" : {
"Type" : "AWS::ElasticBeanstalk::Environment",
"Properties" : {
"ApplicationName" : { "Ref" : "MyApp" },
"Description" : "MyApp environment description",
"UserData" : {
"Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash\n",
"touch /tmp/userdata_sucess\n"
]]
}},
"TemplateName" : "MyAppConfiguration",
"VersionLabel" : "First Cloud version"
}
},
在这两种情况下试图创建堆栈若这导致了失败。有谁知道是否有可能通过的UserData使用CloudFormation一个魔豆实例。如果是这样的 - 你可以提供一个例子
In both cases this resulted in failure when trying to create the stack. Does anyone know if it is possible to pass UserData to a Beanstalk instance using CloudFormation. If so - can you provide an example.
如果你想拥有所有的魔豆提供了优势 - 好像没有修补这亚马逊为你做操作系统 - 这是不可能的。一种选择是,你有必要的脚本来创建一个自定义的AMI,但你必须用你自己的安全补丁管理操作系统。了解更多这里。
If you want to have all the advantages that Beanstalk offers - like not having to patch the OS which Amazon does for you - this isn't possible. One option is to create a custom AMI where you include the needed scripts, but then you must manage the OS yourself with security patches. Read more here.