High Availability Structure in AWS using CloudFront

High Availability Structure in AWS using CloudFront

Let's discuss some basics first.

What is Cloud Computing?

Cloud computing is the on-demand availability of computer system resources, especially data storage (cloud storage) and computing power, without direct active management by the user. The term is generally used to describe data centers available to many users over the Internet. It doesn't store any data on the hard disk of your personal computer. In cloud computing, you can access data from a remote server.

What is AWS ?

Amazon Web Services (AWS) is the world's most comprehensive and broadly adopted cloud platform, offering over 175 fully featured services from data centers globally. Amazon web service is a platform that offers flexible, reliable, scalable, easy-to-use and cost-effective cloud computing solutions. AWS is a comprehensive, easy to use computing platform offered Amazon.

What is EC2 ?

Amazon Elastic Compute Cloud(EC2) is a part of Amazon's cloud-computing platform, Amazon Web Services, that allows users to rent virtual computers on which to run their own computer applications. It is a virtual server in for running applications on the Amazon Web Services (AWS) infrastructure. EC2 is a service that allows business subscribers to run application programs in the computing environment.

What is EBS ?

AWS Elastic Block Store (EBS) is Amazon's block-level storage solution used with the EC2 cloud service to store persistent data. This means that the data is kept on the AWS EBS servers even when the EC2 instances are shut down.

What is S3 ?

Amazon Simple Storage Service(S3) is a service offered by Amazon Web Services that provides object storage through a web service interface. Amazon S3 uses the same scalable storage infrastructure that Amazon.com uses to run its global e-commerce network. It offers industry-leading scalability, data availability, security, and performance.

What is CloudFront ?

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. Content delivery networks provide a globally-distributed network of proxy servers which cache content, such as web videos or other bulky media, more locally to consumers, thus improving access speed for downloading the content.

CloudFront delivers your content through a worldwide network of data centers called edge locations. When a user requests content that you're serving with CloudFront, the user is routed to the edge location that provides the lowest latency (time delay), so that content is delivered with the best possible performance.

What does High Availability Structure mean ?

High Availability systems are dependable enough to operate continuously without failing. They are well-tested and sometimes equipped with redundant components. They can be accessed anywhere in the world with low latency. Moreover, they also showcase high speed delivery of content.

---------------------------------------------------------------------------------------------------------------

Now, let's move on to practical part.

Step 1 : Download AWS CLIv2.

You can refer to this link: https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-windows.html

Check whether successfully installed or not using aws --version command.

No alt text provided for this image

Step 2 : Configure AWS CLI in Windows CMD.

For configuring use command aws configure.

No alt text provided for this image

Step 3 : Create a new Key-pair.

  • Initially there are only these key pairs in my aws account.
No alt text provided for this image
  • Now, create a key pair by command : aws ec2 create-key-pair --key-name ANYNAME --output-text > ANYNAME.pem
No alt text provided for this image
  • Now, a new key pair has been created in my account.
No alt text provided for this image

Step 4 : Create new Security Group and add inbound rules.

  • Create a new security group using command : aws ec2 create-security-group --group-name ANYNAME --description "desc"
No alt text provided for this image
  • Now, a new sg is created in my account.
No alt text provided for this image
  • Add inbound rules to sg using command : aws ec2 authorize-security-group-ingree --group-name GroupName --group-id SG-Id --protocol tcp --port PortNo. --cidr 0.0.0.0/0
No alt text provided for this image
  • Now, my sg have two inbound rules.
No alt text provided for this image

Step 5 : Launch a new EC2 instance.

  • Launch a new EC2 Instance using command : aws ec2 run-instances --image-id ImageId --instance-type t2.micro --count 1 --security-group-ids SG-Id --key-name ANYNAME --subnet-id SUBNETId
No alt text provided for this image
No alt text provided for this image
  • Now, a new instance is launched.
No alt text provided for this image

Step 6 : Create an EBS volume and attach it to the instance.

  • Create an EBS Volume using command : aws ec2 create-volume --availability-zone ap-south-1a --size1 --volume-type gp2
No alt text provided for this image
  • Now a new volume of 1 GB is created in my account.
No alt text provided for this image
  • Now, attach this volume to instance using command : aws ec2 attach-volume --instance-id InstanceId --volume-id VolumeId --device /dev/sdh
No alt text provided for this image
  • It is attached to my instance now.
No alt text provided for this image
No alt text provided for this image

Step 7 : Doing SSH Login to the instance via Windows.

  • Use the highlighted command for your instance to do ssh login.
No alt text provided for this image
No alt text provided for this image

Step 8 : Configuring apache webserver on EC2 Instance.

  • Install httpd server using command sudo yum install httpd -y
No alt text provided for this image
  • Starting webserver service using sudo systemctl start httpd and checking status using sudo systemctl status httpd
No alt text provided for this image

Step 9 : Creating a partition and mounting it on /var/www/html folder.

  • Check the available volumes using sudo fdisk -l
No alt text provided for this image
No alt text provided for this image
  • Create a partition using sudo fdisk /dev/xvdh
No alt text provided for this image
  • Format the partition using sudo mkfs.ext4 /dev/xvdh
No alt text provided for this image
  • Mount the partition on /var/www/html folder using sudo mount /dev/xvdh /var/www/html
  • Check using command df -h
No alt text provided for this image

Step 10 : Creating a S3 Bucket and storing static objects such as pictures

  • Create a S3 bucket using command : aws s3api create-bucket --bucket ANYNAME --region ap-south-1 --create-bucket-configuration LocationConstraint=ap-south-1
No alt text provided for this image
  • Now, my bucket is created.
No alt text provided for this image
  • Putting an image in this S3 Bucket using command : aws s3 cp FILEPATHWITHNAME s3://BucketName/ --acl public-read-write
No alt text provided for this image
  • Now, my image is uploaded in the bucket. Copy the Object URL to the image.
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Step 11 : Creating a webpage and checking S3 image.

  • Again login to your instance via ssh in the same way.
  • Go to /var/www/html folder via command sudo cd /car/www/html
  • Create a webpage using vi WebpageName.html
  • Write a small html script and use the same URL which we copied from S3 Bucket.
No alt text provided for this image
  • Open the webpage in browser using public IP of instance and name of webpage.
No alt text provided for this image

Step 12 : Setting up Content Delivery Network using CloudFront and using the origin domain as S3 bucket.

  • Create a new CloudFront Distribution using command : aws cloudfront create-distribution --origin-domain-name BucketName.s3.amazonaws.com
No alt text provided for this image
No alt text provided for this image
  • Now, my distribution is created. Copy the domain name url.
No alt text provided for this image
No alt text provided for this image

Step 13 : Placing the Cloud Front URL on the Webpage code for security and low latency.

  • Again login to your instance via ssh in the same way.
  • Go to /var/www/html folder via command sudo cd /car/www/html
  • Open the same webpage using vi WebpageName.html
  • Replace the S3 URL with this CloudFront URL.
No alt text provided for this image
  • Again open the webpage in browser using public IP of instance and name of webpage.
No alt text provided for this image

Now, you will see that the page will load much faster than earlier.

------------------------------------------------------------------------------------------------------------

In this way, we can use CloudFront to create a high availability structure with low latency and high security via AWS CLI.

Thank you !!

To view or add a comment, sign in

More articles by Palak S.

  • IBM - Ansible UseCase

    Let's discuss the fundamental knowledge about Ansible first. What is Ansible? Today's world is the World Of Automation.

  • HADOOP SPLITS DATA SERIALLY OR PARALLELLY ??

    Some Fundamental knowledge..

    2 Comments
  • HADOOP CLUSTER SETUP

    Due to the advent of new technologies, devices, and communication means like social networking sites, the amount of…

  • AUTOMATION USING PYTHON

    Automation is the technology by which a process or procedure is performed with minimal human assistance. Automation or…

    3 Comments
  • How MNCs are getting benefits from AI/ML ?

    So, let's begin with a very basic question which must have arisen in the minds of readers who have just read the…

    2 Comments
  • Using AWS CLI to launch an EC2 Instance - TASK 3 (ARTH)

    Hey Everyone ! In AWS CSA And Developer Training by Vimal Daga Sir, we, learners, are given a task. Task Description -…

    4 Comments
  • Brainly : AWS Case Study

    Before talking about the Case Of Brainly, firstly I would like to discuss briefly about Cloud Computing to form a base…

  • Involvement Of Big Data In MNC's

    An intelligent analysis of data is what you need if you wish to succeed in the coming years. Success is why almost all…

Others also viewed

Explore content categories