Deploying webserver by creating a High Availability Architecture using AWS CLI

The architecture includes-
- Webserver configured on EC2 Instance
- Document Root(/var/www/html) made persistent by mounting on EBS Block Device.
- Static objects used in code such as pictures stored in S3
- Setting up Content Delivery Network using CloudFront and using the origin domain as S3 bucket.
- Finally place the Cloud Front URL on the webapp code for security and low latency.

Step 1: Launch an instance in AWS

General command:

Step 2: Create volume

Create an EBS volume for permanent storage

Step 3: Attach volume to the instance that is created

Attach the volume created in step-2 to the instance created in step-1

By using the command fdisk -l you can view the details of the sector that you have created

Step 4:install httpd

Use the command yum install httpd to install httpd

Enable httpd serviced by using the command systemctl enable httpd

Step 5:Create partition

The next step is to create a partition and save it.

Step 6:Format

Use the command mkfs.ext4 /dev/xvdf to format the partition created in the previous step

Step 7: Mount the partition

The formatted partition must be now mounted on /var/www/html folder using the command mount /dev/xvdf /var/www/html

Using the command df -h , we can verify that our partition has been mounted on the /var/www/html folder

Step 8: Create S3 bucket

The following “mb” command creates a bucket in a region specified by
the “ — region” parameter. In this example, the user makes the bucket
“mybucket” in the region “ap-south-1”:

You can verify through GUI that a bucket has been created

Step 9: Upload static images in s3 bucket

Use the s3 cp command to copy objects from a bucket or a local directory.

Command to upload an image nature.jpg into the bucket created in the previous step
Through GUI, you can see that the image has been uploaded

Setting Permissions

For an object that you’ve already stored in Amazon S3, you can run this command to update its ACL for public read access:

Step 10: Create html webpages

The object URL obtained in the previous step can be used in our html code .

Object URL: https://madhuri12345.s3.ap-south-1.amazonaws.com/nature.jpg

webpage.html file created in /var/www/html folder

Step 11: Create CDN

Create a new web distribution. You create a CloudFront distribution to tell CloudFront where you want content to be delivered from, and the details about how to track and manage content delivery

General command:

We can see in GUI that the distribution has been deployed

Step 12:Place CloudFront URL on webapp code

After creating CDN ,we get the CloudFrontURL : http://d2gigfuxubpv9.cloudfront.net/nature.jpg

This URL can be placed in our html code instead of the ObjectURL written previously.

The reason to perform this step is to provide a better user experience by ensuring security and low latency.

FINAL WEBPAGE

Thanks for reading

-Vijaya Madhuri T A

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