Note that the IP address 111.222.333.444 needs replaced with whatever IP you generate as your elastic IP.
Work in Progress, brain dump from @scarstens
- Create VPC (if not already exists)
- Create security group with "my ip" access to all ports.
- Create security group for "http_https_open" and open 80 and 443 to the public
- Create IAM role for "default_ec2_role", assign it basic S3 read access for now.
- Create EC2 -> Select free teir Ubuntu 16 AMI
- assign it to the VPC, Security Groups, and IAM role created above
- default tags, storage space, and other options all fine as default
- use wizard to create PEM keypair (or select existing keypair) -> download the PEM -> move it to ~/.ssh -> chmod 600 the PEM key
- finalize / spin up instance
- create elastic ip -> assign it to the instance
- ssh into the ec2 instance with something like
ssh [email protected] -i ~/.ssh/KEYNAME.pem
- git clone https://github.com/scarstens/devops-toolkit
- bash devops-toolkit/setup-git-credentials.sh
- if you haven't already, get your github handle (username)
- if you haven't already, generate and prepare your github personal access token https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/
- enter these two items into the prompts (note you won't see anything when it asks for password, this is a security feature)
- bash devops-toolkit/beta/node-express.sh
- curl localhost (should display hello world)
- create github repo with actual node app (private or public at this point)
- stop the current node app
pm2 stop nodeapp
- remove (backup) the sample node app
sudo mv /var/www/nodeapp /var/www/default_nodeapp
- clone your new repo onto the previous nodeapp folder location
git clone https://github.com/myuser/myrepo /var/www/nodeapp
- rebuild the node app based on its package.js
cd /var/www/nodeapp ; npm install --save
- restart the node app runner
pm2 start nodeapp
Now you can update the node app automatically by stopping, git pulling, and starting the node app. Would look something like this:
cd ~/devops-toolkit ; git pull ; bash update-pm2-nodeapp.sh ;'
Or you can run it remotely using a command similar to this:
ssh [email protected] 'cd ~/devops-toolkit ; git pull ; bash update-pm2-nodeapp.sh ;'`