I'm running the following user data script for my AWS EC2 on an Amazon Linux AMI. I want to run a simple socketio server, however whenever I stop and start the instance, the script doesn't run. When I SSH via the Connect portal, and run these commands, it works. Furthermore when creating an AMI from my functioning instance, Git is present but not Node on instances generated from that AMI.
I followed the AWS docs for installing node and it alludes that it should work with an AMI.
#!/bin/bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
. ~/.nvm/nvm.sh
nvm install node
sudo yum install git -y
git clone https://github.com/justincervantes/socketio-server-demo.git
cd socketio-server-demo
npm i
node index.ts
Thanks in advance for your advice.