title: How to run user-data commands in Cloudformation on EC2 as some other user?
body: <p>What I have noticed is whenever user-data commands are executed while executing a Cloudformation template to spin up an EC2, they are run via the root user. How can I change this behaviour so that the commands are run as ec2-user?</p>
  
  <p>I tried doing a </p>
  
  <pre><code>sudo su ec2-user
  </code></pre>
  
  <p>to tackle this, but that apparently opens up another shell on the machine so doesn't really solve this use case.</p>