setup.mp4
- Sign In
- Search EC2
- Hover ove EC2
- Click Dashboard
- Launch instance: Click Launch Instance
- Name and tags: Give it a name
- Application and OS Images (Amazon Machine Image): Choose Ubuntu
- Key pair (login): Create new key pair
- Key pair name: give it a name
- Key pair type: ED25519
- Click Create key pair
- Download file
- Advanced Details: paste user data file
- Click launch instance
#!/bin/bash
sudo apt-get -y update
sudo apt-get -y install postgresql
sudo -u postgres psql -d postgres -c "CREATE USER ubuntu SUPERUSER LOGIN PASSWORD 'ubuntu'";
echo "export PGPASSWORD=ubuntu" >> /home/ubuntu/.profile
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install nodejs
connecting.mov
-
After creation, wait a few minutes for the installation of the tools to complete and click on Connect to instance
-
From EC2 Dashboard:
- Resources: click Instances (running)
- Click Instance ID
- Click Connect
-
Click SSH Client of not already chosen
-
Locally, locate directory containing .pem file
-
chmod 400 pern.cer
(substitute filename for pern.cer) -
copy Example connect command from AWS page
-
confirm connecting
github.mp4
- clone repo via https
cd
into reponpm i
- start tmux session
node server.js
tmux new -s mernapp
to start sessionctrl+b d
to detachtmux ls
list sessionstmux attach-session -t mernapp
reattach sessiontmux kill-session -t mernapp
destroy session- (
ctrl+c
to stop process and thenexit
from within tmux is preferable)
- (
aws_console.mov
- Go to EC2 Dashboard
- Resources: Click on Instances (running)
- Click on Instance ID
- Click on Security Tab
- Click on link under Security Groups
- Click on Edit inbound rules
- Click on Add Rule
- Choose Custom TCP
- For Port range enter 3000 or whatever
- each time a new app is deployed, a new unique port number must be opened and the app must listen on it
- For Source choose Anywhere-IPv4
- Click Save rules
- Click on Instances
- Click on Insance ID
- Copy Public IPv4 address or Public IPv4 DNS
- Paste into browser and add :3000 after it
elastic_ips.mov
- In EC2 Dashboard, click on Elastic IPs in left menu bar
- Click "Allocate Elastic IP address"
- Click "Allocate"
- Click on "Actions" dropdown
- Choose "Associate Elastic IP address"
- Click into "Instance" text input
- Choose your instance from autocomplete option
- Click on "Associate"
- Click on "Instances" in left menu bar
- Click on instance id
- Note existence of "Elastic IP Address"
- Use this IP address instead of previous IP address.
AWS sporadically restarts EC2 instances with no warning. The simplest solution is to use https://www.downnotifier.com/
- Enter Website URL
- Enter your email address
- Make sure "Notify Me: When the site is offline" is selected
- Click "Start monitoring my website"