Quick Guide for AWS

Valentsea
Total
0
Shares



Deploy to EC2




Security Group

Setup the following security group configuration

Preffered security group for ec2 instance



Connect with SSH

  • Update the permission of downloaded certificate file
chmod 400 .pem
Enter fullscreen mode

Exit fullscreen mode

  • Connect to the distant server with the command
ssh -i .pem ec2-user@
Enter fullscreen mode

Exit fullscreen mode



Install node with nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
Enter fullscreen mode

Exit fullscreen mode

. ~/.nvm/nvm.sh
Enter fullscreen mode

Exit fullscreen mode

nvm install node
Enter fullscreen mode

Exit fullscreen mode

  • Test node installation with
node -e "console.log('Running Node.js ' + process.version)"
Enter fullscreen mode

Exit fullscreen mode

Checkout the official documentation on how to setup node in ec2 linux



Port Forwarding from 80 to 8000

Use the following command for port forwarding

sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8000
Enter fullscreen mode

Exit fullscreen mode



Install MongoDB community edition

  • Verify Linux Distribution with
grep ^NAME  /etc/*release
Enter fullscreen mode

Exit fullscreen mode

The result should be Amazon Linux or Amazon Linux AMI

  • Create a /etc/yum.repos.d/mongodb-org-4.4.repo file so that you can install MongoDB directly using yum:
cd /etc/yum.repos.d
sudo touch mongodb-org-4.4.repo
Enter fullscreen mode

Exit fullscreen mode

  • Add the following Configuration to created file with nano or vim
[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
Enter fullscreen mode

Exit fullscreen mode

  • Install MongoDB packages with
sudo yum install -y mongodb-org
Enter fullscreen mode

Exit fullscreen mode

  • Setup storage directory for MongoDb
cd /
sudo mkdir data
cd data
sudo mkdir db
cd ../..
cd home/ec2-user
Enter fullscreen mode

Exit fullscreen mode

sudo service mongod start
Enter fullscreen mode

Exit fullscreen mode

Checkout common errors faced during this

Checkout the offficial Documentation



Install PostgreSQL

Follow this article for installing PostgreSQL

after install use this command to open db shell

sudo su - postgres
Enter fullscreen mode

Exit fullscreen mode



Transfer node project to ec2

You can use programs like filezilla to transfer project files the method I use personally is to send zipped file using scp command

  • Delete node_modules directory from project
  • Zip the project directory
zip -r server.zip 
Enter fullscreen mode

Exit fullscreen mode

  • Transfer zipped file using scp
scp -i .pem server.zip ec2-user@:
Enter fullscreen mode

Exit fullscreen mode

  • Now connect back to instance with SSH and unzip the file
unzip server.zip
Enter fullscreen mode

Exit fullscreen mode



Run Application with screen

install the node modules and run the app with screen

screen npm start
Enter fullscreen mode

Exit fullscreen mode

you can detach the screen without terminating by

i. ctrl+A
ii. D




Bucket Policy for S3


Use the following bucket policy in S3 Bucket for public read access

{
    "Version": "2008-10-17",
    "Statement": [
        {
            "Sid": "AllowPublicRead",
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::/*"
        }
    ]
}
Enter fullscreen mode

Exit fullscreen mode




CloudFront Guide


Use this tutorial for setting up cloudfront




Steps to get SSL Certificate to EC2 instance


  1. move nameserver to Route 53
  2. request certificate from ACM
  3. create load balancer targeting to ec2 instance
  4. create a record pointing to load balancer in route 53
Total
0
Shares
Valentsea

Exploratory Data Analysis Ultimate Guide

Exploratory Data Analysis (EDA) is a crucial process in any data analysis project. It involves examining, cleaning, and…

You May Also Like