This Is How I Deploy My First NestJS Application into AWS EC2

What is AWS EC2?

Let’s Get Our Hands Dirty

ssh -v -i /Users/jsantos/Downloads/my-nest-application.pem ec2-user@ec2–18–188–20–76.us-east-2.compute.amazonaws.com
  • -v is a flag to show logs when running the command (not required)
  • -i is a flag to specify where the pem key is located (required)
ec2-user@[Public DNS]
  • ec2-user@ is the username for some AWS Linux machines (Amazon Linux 2 or the Amazon Linux AMI). We are using Amazon Linux AMI.
Permissions 0644 for '/Users/jsantos/Downloads/my-nest-application.pem' are too open.It is required that your private key files are NOT accessible by others.This private key will be ignored.Load key "/Users/jsantos/Downloads/my-nest-application.pem": bad permissionsdebug1: No more authentication methods to try.ec2-user@ec2-18-188-20-76.us-east-2.compute.amazonaws.com: Permission denied (publickey).
chmod 400 /Users/jsantos/Downloads/my-nest-application.pem
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
. ~/.nvm/nvm.sh
nvm install node
node -v 
# Perform a quick update on your instance:sudo yum update -y# Install git in your EC2 instancesudo yum install git -y
git clone https://github.com/nestjs/typescript-starter
cd typescript-starter && npm install
npm run build
npm run start:prod
http://18.188.20.76:3000

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store