Running commands upon creation of instances using AWS Elastic Beanstalk
<p>I've been looking at various methods to run commands upon creation of EC2 instances using Elastic Beanstalk on AWS. I've been given different methods to do this through AWS Tech Support, including life cycle hooks, custom AMI's, and .ebextensions. I've been having issues getting the first 2 methods (life cycle hooks and custom AMIs) to work with EB.</p>

<p>I'm currently using .ebextensions to run commands upon deploy, but not sure if there's a way to run a set of commands upon creation only instead of every time I deploy code. For instance, I have a file <code>.ebextensions/03-commands.config</code> that contains the following code:</p>

<pre><code>container_commands:
  01_npm_install:
    command: "npm install -g -f npm@latest"
</code></pre>

<p>However, I only want this code to run upon instance creation, not every time I deploy, as it currently does. Does anyone know a way to accomplish this?</p>

<p>Thanks in advance!</p>