I cannot get my newly launched ec2 instances to run the User Data script specified in Advanced Settings -> User Data.
If I manually SSH into my instance after it is done initializing and type "cd DIRECTORY", & "npm run SCRIPT" the instance will run the NodeJS app perfectly. However I cannot get the User Data script to do this automatically on ec2 instance initialization.
I saw in similar articles to include "#!/bin/bash" at the beginning of my script but this has not made a difference.
When launching a new instance, in Advanced Settings -> User Data script I have:
#!/bin/bash <- tried with and without this
cd DIRECTORY
npm run SCRIPT
Which is the exact command I use to run my NodeJS app by manually SSH-ing into the instance. Is there something I am missing??
I am launching an Amazon Linux T3.micro instance from my AMI.
Any ideas on how to troubleshoot or fix this??