Implementing a High Availability Architecture using Cloudfront in AWS CLI…

Kaustubh Chaudhari
6 min readOct 30, 2020
A Short video description of Cloudfront service…

What is AWS CLI ?

AWS CLI is the commannd line Interface provided by AWS cloud services to access all the AWS cloud services using command line without going physically to AWS console GUI . Many of important use cases which GUI can’t solve can be solved using CLI.

What is EBS Volume ?

EBS stands for Elastic Block Storage. An Amazon EBS volume is a durable, block-level storage device that you can attach to your instances. After you attach a volume to an instance, you can use it as you would use a physical hard drive. EBS volumes are flexible. For current-generation volumes attached to current-generation instance types, you can dynamically increase size, modify the provisioned IOPS capacity, and change volume type on live production volumes.

What is S3 Service in AWS ?

Amazon S3 has a simple web services interface that you can use to store and retrieve any amount of data, at any time, from anywhere on the web. It gives any developer access to the same highly scalable, reliable, fast, inexpensive data storage infrastructure that Amazon uses to run its own global network of web sites. The service aims to maximize benefits of scale and to pass those benefits on to developers.

What is AWS Cloudfront Service ?

Amazon CloudFront is a fast content delivery network (CDN) service that securely delivers data, videos, applications, and APIs to customers globally with low latency, high transfer speeds, all within a developer-friendly environment. CloudFront is integrated with AWS — both physical locations that are directly connected to the AWS global infrastructure, as well as other AWS services. CloudFront works seamlessly with services including AWS Shield for DDoS mitigation, Amazon S3, Elastic Load Balancing or Amazon EC2 as origins for your applications, and Lambda@Edge to run custom code closer to customers’ users and to customize the user experience. Lastly, if you use AWS origins such as Amazon S3, Amazon EC2 or Elastic Load Balancing, you don’t pay for any data transferred between these services and CloudFront.

It uses the AWS internal private network to transfer data between two Edge Locations. Edge Locations are the small Datacentres which are used to provide CDN.

Why Cloudfront is Better in UX (User Experience)over S3 and EBS ?

We transfer data over network in the form of packets. My packet travels through multiple ISP’s server to go from Source to Destination.Nobody can give guarentee about network speed because ISP server can go down any time. While accessing data using S3 and EBS volume AWS uses the Internet i.e Public route which is very crowded and sometimes give low speed. Latency is high in this route.

If the server is in one Country and Client is in other country then it takes a lot of time for a packet to reach there due to problem of Internet. Due to this the User Experience become worse. So, to improve UX we use the CDN service named Cloudfront in AWS. AWS uses it’s private network to transfer data between Edge Locations. Cloudfront is highly secured , fast and low latency service.

Steps to configure this Architecture :=

Prerequisites :=

  1. You must have AWS account.
  2. Login to AWS CLI through IAM user .

1. Launch AWS Instance :=

we can also lauch new instance using command”aws ec2 run-instances — image-id ami-052c08d70def0ac62 — instance-type t2.micro — count 1 — subnet-id subnet-31595659 — security-group-ids sg-026ea953028eef330 — key-name kaustubh1".

Instance Launched

2. Create an EBS Volume :=

Create Volume := we use command “aws ec2 create-volume — availability-zone ap-south-1a — size 1”.

3. Attach EBS volume to EC2 Instance :=

Attach Volume to newly created Instance := we use command “aws ec2 attach-volume — voulme-ids vol-08eaf1d6bdaefa72e instance-ids i-045a51652614f37e5 — device /dev/sdf”.

4. Configure Web Server On Instance and create small website :=

  • To configure Web Server, we need to install apache server i.e httpd and to install httpd use command : yum install httpd
  • Start the Server using command : systemctl start httpd
  • check status of the server using command : systemctl ststus httpd
Webserver is started successfully …

5. Create partition , format it and mount it to /var/www/html directory :=

  • Create Partition : fdisk /dev/xvdf
  • After running this command perss ’n’ for new partition ‘p’ for list of partitions and ‘w’ to save the partition.

Successfully created partition.

  • Format the partition : mkfs.ext4 <name of partition>
  • Mount the Partion to /var/www/html file : mount /dev/xvdf /var/www/html.
  • See if mounted : df -h

Now create a HTML file inside directory /var/www/html and create a page .

6. Create S3 Bucket and upload image to it :=

  • create S3 bucket use the command : aws s3api create-bucket — bucket <bucket name > — region <region name > — create-bucket-configuration LocationConstraint=<region name>

We can confirm it from this :

  • Upload image in S3 Bucket and open image and copy path :

7. Create Cloudfront distribution :=

To create a Cloudfront Distribution use the command: aws cloudfront create-distribution — origin-domain-name <bucket domain>

We can confirm it as :

Now copy this link in Html file.

  • Now open the site through Public ip and file name : http://<ip>/<file name>

Thank you !!!!

--

--