Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to pass user data as a parameter. #104

Closed
mhussain opened this issue Apr 14, 2016 · 5 comments
Closed

Ability to pass user data as a parameter. #104

mhussain opened this issue Apr 14, 2016 · 5 comments

Comments

@mhussain
Copy link

Requesting the ability to pass user data as parameter to the stack instead of having to write in inline in the template.

Something like

DateInit: files/user_data.txt
"DataInit": {
  "Type": "String",
  "Description": "Initialisation script"
}
...

"UserData": { "Fn::Base64": { "Ref": "DataInit" } }

...
@simpsora
Copy link
Contributor

👍 to this idea -- it would be nice to have UserData content extracted to a separate file.

For this to be most useful, the content of the would still need to be parsed by CloudFormation, in order to resolve intrinsic functions (Fn::Ref, Fn::GetAtt, etc.). Use of those functions may introduce some strange requirements when it comes to quoting the content.

@stevehodgkiss
Copy link
Contributor

I saw an interesting solution to this in a sparkleformation issue: sparkleformation/sparkle_formation#54 (comment)

It enables separate user data files while being able to use ERB to call sparkle functions inside that file like <%= region! %>.

@simpsora
Copy link
Contributor

@stevehodgkiss that's an interesting approach, although it's a shame that it only works with Sparkle. I'd love to see a more generic approach if possible (though I don't currently see how).

cloud-init has quite a bit more functionality than just user-data shell scripts, see here:
https://help.ubuntu.com/community/CloudInit

About the only idea I have is to create a grammar of some kind to allow embedding CF references/functions inline in the script, then replacing them with closequote-var-openquote:
...", { "Ref" : "Foo" }, "...

@simpsora
Copy link
Contributor

@mhussain: 0.6.0 has been released, which contains user_data_file!. See #117 for details.

@stevehodgkiss
Copy link
Contributor

I think the approach/code used in #117 could be used in JSON/YAML templates quite easily too, we'd just need to run it through the same Erubis context. It could look like this:

  "UserData": <%= user_data_file!('app.erb') %>

@simpsora simpsora closed this as completed Nov 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants