Amazon Web Services (AWS) is Amazon's cloud computing platform that offers a wide range of services like virtual servers, storage, databases, and networking on a pay-as-you-go basis. It provides on-demand infrastructure and tools for individuals, companies, and governments to build, scale, and run applications, websites, and other services in the cloud, leveraging economies of scale and industry-leading security.
Amazon Simple Storage Service (S3) is a storage service that lets you create buckets and store objects inside of them. Common use cases of AWS S3 include backing up data, archiving, storing and sharing files, hosting static websites, supporting analytics, and storing logs or machine learning data.
grants-dev-toolkit Amazon CloudFront is a content delivery network (CDN) that speeds up distribution of static and dynamic web content such as .html, .css, or .js and image files, from edge locations close to users to improve performance.
good-css-cdn grants-dev-toolkit.s3.us-east-1.amazonaws.com /production (this should only be a folder, not a file) https://d11dibs3lqrpwz.cloudfront.net/Good.css /Good.css
/*
These paths are removed from the CloudFront cache. After invalidation, the next time a user requests the file, CloudFront fetches the updated version from the origin so users see the correct content immediately.
Amazon Elastic Compute Cloud (EC2) provides on-demand, resizable virtual servers (called instances) in the cloud for running various applications, offering flexible computing capacity without upfront hardware costs.
Common use cases of AWS EC2 include running websites and applications, hosting databases, handling batch processing, supporting machine learning workloads, and creating scalable cloud servers.
Ubuntu Server 24.04 LTS (HVM), SSD Volume Type t2.nano 1x 8 GiB gp3 Root volume, 3000 IOPS, Not encrypted Note: When creating an EC2 instance, the type depends on the type of instance upon creation (Amazon Linux = ec2-user whereas Ubuntu = ubuntu).
ssh -i [location of key] [type]@[Public IPv4 address]
ssh -i grants_dev_tools_key.pem ec2-user@18.234.88.211
# Create a copy of the file/folder you want to upload
# cp -r directory
# Before you copy your folder to an EC2 instance, remove any files or folders you do not want copied over
cd directory
rm -rf .git
rm -rf node_modules
# Secure copy (SCP) the folder you want copied to the EC2 instance along with your key
scp -i ./Code/Keys/grants_dev_tools_key.pem -r grants_dev_tools ec2-user@184.73.21.17:/home/ec2-user/
# The inside the EC2 Instance is bare bones and has nothing.
# If Amazon Linux
sudo yum update -y
sudo yum install -y nodejs npm
cd directory
npm i
# If Ubuntu or Debian
sudo apt update
sudo apt upgrade
# You need to install a web server
sudo dnf -y httpd
# Remove the old file/folder in the /var/www/html directory
sudo rm -rf /var/www/html/*
# Secure copy the newly uploaded file/folder to the /var/www/html directory
sudo cp -r /home/ec2-user/grants_dev_tools_updated/* /var/www/html/
# Exit the EC2 instance
exit
ssh -i ./Code/Keys/grants_dev_tools_key.pem ubuntu@54.147.152.76
# Connect via SSH
ssh -i ./keys/ec2_key.pem ubuntu@54.147.152.76
# Update and Upgrade
sudo apt update
sudo apt upgrade
# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
node --version
node
console.log("We're using Node on an EC2 instance!");
# Copy Files and Folders w/ Rsync - Be inside the folder you want to copy!
rsync -avz --exclude 'node_modules' --exclude '.git' --exclude '.env' \
-e "ssh -i ../Code/Keys/grants_dev_tools_key.pem" \
. ubuntu@54.147.152.76:~/app
# Install Dependencies
sudo npm install
sudo npm install -g pm2
# Install NGINX
sudo apt update
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
sudo nano /etc/nginx/sites-available/express-app
# Copy and paste the NGINX code below
sudo ln -s /etc/nginx/sites-available/express-app /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default
sudo nginx -t
sudo systemctl reload nginx
# Add Domain Name and HTTPS
# Set Up PM2
pm2 start server.js
pm2 save
pm2 startup systemd # This will print something similar to: sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u ubuntu --hp /home/ubuntu. Run that command.
sudo reboot
# Reconnect to the EC2 using SSH: ssh -i ./Code/Keys/grants_dev_tools_key.pem ubuntu@54.147.152.76
pm2 list
# Exit the EC2 instance
exit
Note: ec2-98-88-77-166.compute-1.amazonaws.com is the Public DNC address.
Note: You need to add a custom rule for allowing port 3000 to work. Only HTTP works, NOT HTTPS: http://98.88.77.166:3000/.
Note: PM2 is a process manager for Node.js. It is used to keep the server running automatically.
Note: The -r is used to recursively copy a directory.
server {
listen 80;
server_name _;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Amazon Lambda is a serverless, secure, on-demand, event-driven, compute service that scales as needed and billed only for what is used. It allows users to run code without provisioning or managing servers. This means that users can focus on writing their application logic, and Lambda automatically handles the underlying infrastructure, including scaling, patching, and maintenance.
Common use cases of AWS Lambda include running event-driven code, automating tasks, processing data streams, building serverless applications, and integrating with other AWS services.
Coming soon...