I have tried
base64 encoded UserData
None of them worked.
I used to use Java SDK with userdata-file option.
So I wish to use that rather than pass UserData as a String.
But I cannot find that param in AWS-SDK-js.
It must be base64 encoded as per the documentation on EC2 (http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-RunInstances.html), but it seems this information is omitted from our API docs. This can be corrected.
FYI I've updated SDK documentation for the UserData parameter to notify users that the value should be Base64-encoded. This update will go out with our next release. Thanks for reporting this!