[Rails deploy — Part 1] Prepare EC2 instance for deploy Rails app

Cuong Nguyen
Nov 5, 2020

1. Create EC2 instance

Login to AWS console

In the find service input find EC2

Before create EC2 instance, we are going to create sercurity_group for all EC2 instance running rails

in the left side bar, click on sercurity group

Create inbound and outbound rule like the image below:

And now we start to create the EC2 instance

Going back to dashboard EC2 and click on Launch instance button

choose Ubuntu Server 20.04 LTS (HVM), SSD Volume Type — ami-093da183b859d5a4b (64-bit x86) / ami-052e689356eaf7423 (64-bit Arm) intanse

In Step 2:

choose the size of instance base on your budget and purpose

Next to step 3: Click on Next Step

Next to step 4: Click on Next Step

Next to step 5: Click on Next Step

Next to step 6: choose the existing security group, and then choose the previously created security group

2. SSH to EC2 instance and set up key pair

cd to the folder contain the key download from aws

go to AWS console, tick on the new instance > click on click button > copy the code to SSH to server

return to terminal and paste the line of code, and enter to SSH to server. Result:

Create deploy user on the server terminal

sudo adduser deploy

sudo adduser deploy sudo

su deploy

cd ../deploy/

--

--