I need an application server, which is a beanstalk instance, to do some startup work, and I was thinking of running a bash script passed to the instance with the UserData property available for regular EC2 instances.
I found some examples of CloudFormation templates that do this with regular EC2 instances, but there is no Beanstalk example. I tried adding 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 part of the environment:
"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" } },
In both cases, this caused a crash when trying to create a stack. Does anyone know if it is possible to pass UserData to a Beanstalk instance using CloudFormation. If so, can you give an example.
source share