This content originally appeared on DEV Community and was authored by Mohammed Shaheem P
Deploy to EC2
Security Group
Setup the following security group configuration
Connect with SSH
- Update the permission of downloaded certificate file
chmod 400 <file_name>.pem
- Connect to the distant server with the command
ssh -i <certificate>.pem ec2-user@<Public_IPv4_DNS>
Install node with nvm
- Download nvm using curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
- Activate nvm with
. ~/.nvm/nvm.sh
- Install node with
nvm install node
- Test node installation with
node -e "console.log('Running Node.js ' + process.version)"
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
Install MongoDB community edition
- Verify Linux Distribution with
grep ^NAME /etc/*release
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
- 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
- Install MongoDB packages with
sudo yum install -y mongodb-org
- Setup storage directory for MongoDb
cd /
sudo mkdir data
cd data
sudo mkdir db
cd ../..
cd home/ec2-user
- Start mongodb service
sudo service mongod start
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
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 <project_directory>
- Transfer zipped file using scp
scp -i <certificate>.pem server.zip ec2-user@<Public_IPv4_DNS>:
- Now connect back to instance with SSH and unzip the file
unzip server.zip
Run Application with screen
install the node modules and run the app with screen
screen npm start
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:::<bucket_name>/*"
}
]
}
CloudFront Guide
Use this tutorial for setting up cloudfront
Steps to get SSL Certificate to EC2 instance
- move nameserver to Route 53
- request certificate from ACM
- create load balancer targeting to ec2 instance
- create a record pointing to load balancer in route 53
This content originally appeared on DEV Community and was authored by Mohammed Shaheem P
Mohammed Shaheem P | Sciencx (2023-02-26T07:40:59+00:00) Quick Guide for AWS. Retrieved from https://www.scien.cx/2023/02/26/quick-guide-for-aws/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.