title: How to run a script on a newly created EC2 instance via AWS SDK?
body: <p>I'm currently using AWS's Javascript SDK to launch custom EC2 instances and so far so good.</p>
  
  <p>But now, I need these instances to be able to run some tasks when they are created, for example, clone a repo from Github, install a software stack and configure some services.</p>
  
  <p>This is meant to emulate a similar behaviour I have for local virtual machine deployment. In this case, I run some provisioning scripts with Ansible that get the job done.</p>
  
  <p>For my use case, which would be the best option amongst AWS's different services to achieve this using AWS's Javascript SDK?</p>
  
  <p>Is there anyway I could maybe have a template script to which I passed along some runtime obtained variables to execute some tasks in the instance I just created? I read about <code>user-data</code> but I can't figure out how that wraps with AWS's SDK. Also, it doesn't seem to be customisable.</p>
  
  <p>At the end of the day, I think I need a way to use the SDK to do this: </p>
  
  <blockquote>
    <p>"On the newly created instance, run this script that is stored in such place, replacing these
    placeholder values in the script with these I'm giving you now"</p>
  </blockquote>
  
  <p>Any hints?</p>