AWS Project (Web Application Deployment)

Nishchay Agrawal
8 min readJun 21, 2024

--

What is Web application — It is a stand-alone application.

It will be having HTML contents.

Steps:
1) created a vpc
2) created subnets
3) created route-tables, internet-gateway
4) configured rt,igw and subnets
5) created an ec2 instance
6) installed apapche2 webserver
7) cloned my app from GitHub and moved /var/www/html folder(delete default index.html before moving)
8) purchased a domain
9) create hosted-zone with the domain name
10) copied the ns records into the domain provider
11) create A record in route53 hosted zone
12) browse application with the domain name

Should have an AWS account.

We need to have own network (VPC).

Step 1 : create a VPC

- Provide the Ip range — 20.0.0.0/16

  • Name: my-vpc

16 — the number of Ip addresses that will be allocated.

There is a formula to calculate the Ip address:

2^(32-n)

n is nothing but the CIDR range (Classless inter-domain routing or subnetting)

Here 16 is CIDR.

2^(32–16) =2^(16)=65536

(Few ip address will be used for internal purpose by the aws,

1 subnet = 5 ip address cannot be used for our requirements.)

Click on create VPC :

Enable the DNS hostnames (by default it will be diassabled):

Step 2 — Create Subnets.

How to calculate the subnets?

Mention the vpc range (20.0.0.0/16)

What is subnet?

It is the grouping of ip address within the vpc .

Mention the required number of subnets.

Copy the subnet address to the CIDR range

Create 4 subnets (2 public and 2 private subnets) .

Enable auto-assign public IPv4 address

Step 3 — Create Route Table and Internet Gateways.

Assign public subnet and save associations .

Create a private route table in the same way, assigning private subnets and save association.

Create Internet Gateway.

Give the name tag as my-igw and click on create internet gateway .

Step 4 — Configure route tables , subnets and Internet Gateway.

Attach the internet gateway to VPC.

Go to public subnet and add the internet gateway to the routes.

And save changes.

Now the private subnet will not have public access from outside the vpc.

It can only be accessed within the vpc.

Step 5 -Create an EC2 Instance.

Enable HTTP traffic , because I want to run my application with port 80

Select the custom vpc and public subnet , because public subnet will be accessible to outside world.

Launch instance.

Login to the EC2 instance through terminal for mac , you can use git bash or putty for windows users.

“Chmod 400 nvirginia.pem” will change the permissions of the key .

Successfully logged in .

Create another private-instance with private subnet .

The private-instance cannot be connected according to our architecture as we have not exposed public subnet to the outside world.

Web server — helps to run the static web applications .

Step 6 — Install the Apache2 webserver .

Apache2 — It is a webserver which helps to run the static web application .

Systemctl start apache2 — run the apache service

Systemctl stop apache2 — will stop the apache service

Systemctl enable apache2 — after reboot it will automatically start the service .

Install Git .

Step — 7: Now clone the application from GitHub to instance .

The application will be cloned .

Now unzip the file .

Rename the folder to mywebapp.

This is the source code .

Place it under the path /var/www/html/

Delete the default index.html and place entire source code.

The page will be modified.

Now move the source code .

Now reload the page .

Let’s provide a domain to access instead of the Ip address.

Step 8 — Purchase a domain .

Here I have purchased mine already from godaddy.com

Now go to route53 in AWS.

Step 9 : Create the Hosted Zone with the Domain Name .

Provide the purchased domain name .

Go with public hosted zone .

Source Of Authority is where the domains is managed.

Name Servers helps to manage the domain .

Go to godaddy , Manage — DNS — Nameservers — Change Nameservers.

Step 10 — Copy the nameservers from Route53 and replace it in Go daddy Nameservers and click save .

Step 11 : Create a A record in Route53.

For mapping IP address with can go with A record .

Paste the public IP address.

Change TTL to 60 sec, select simple routing and create records.

Step 12 : Now we can browse the application with the domain name.

--

--

Nishchay Agrawal

Software Development Engineer-3 (Data Engineer- III ) @ Walmart | SDE-2(Data) @ Meesho| Ex-Data Engineer at Morgan Stanley | Gold Medalist-Uttarakhand Topper