Creating High Availability With AWS CLI (S3 , EBS , CloudFront) !!!
Anushka Visapure
Solution-Oriented DevOps Engineer || Skilled in Kubernetes | Terraform | Ansible | Docker | Git and GitHub | GitHub Action || Expanding Capabilities in AWS | GCP | Linux.
What is a Web-Server?
A web server is software and hardware that uses HTTP (Hypertext Transfer Protocol) and other protocols to respond to client requests made over the World Wide Web. The main job of a web server is to display website content through storing, processing and delivering webpages to users. Besides HTTP, web servers also support SMTP (Simple Mail Transfer Protocol) and FTP (File Transfer Protocol) used for email, file transfer and storage.
Web server hardware is connected to the internet and allows data to be exchanged with other connected devices, while web server software controls how a user accesses hosted files. The web server process is an example of the client/server model. All computers that host websites must have web server software.
Web servers are used in web hosting, or the hosting of data for websites and web-based applications or web applications.
What is EBS?
Elastic Block Store (EBS) is a block storage service based in the AWS cloud. EBS stores huge amounts of data in blocks, which work like hard drives (called volumes). You can use it to store any type of data, including file systems, transactional data, NoSQL and relational databases, backup instances, containers, and applications. EBS is usually used for
EBS is offered through the AWS platform, and requires an AWS account. The platform enables you to optimize performance and pricing. For example, you can change the volume size and type, and delete redundant volumes. From the platform, you can configure backup and recovery options for your data.
What is S3 bucket?
S3 bucket is a public cloud storage resource available in Amazon Web Services' (AWS) Simple Storage Service (S3), an object storage offering. Amazon S3 bucket, which are similar to file folders, store objects, which consist of data and its descriptive metadata.
What is Cloud Front ?
Amazon CloudFront is a web service that speeds up distribution of your static and dynamic web content, such as .html, .css, .js, and image files, to your users.
How does cloud Front Work?
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 is a CDN?
A content delivery network (CDN) refers to a geographically distributed group of servers which work together to provide fast delivery of Internet content.
A CDN allows for the quick transfer of assets needed for loading Internet content including HTML pages, javascript files, stylesheets, images, and videos. The popularity of CDN services continues to grow, and today the majority of web traffic is served through CDNs, including traffic from major sites like Facebook, Netflix, and Amazon.
How does a CDN work?
At its core, a CDN is a network of servers linked together with the goal of delivering content as quickly, cheaply, reliably, and securely as possible. In order to improve speed and connectivity, a CDN will place servers at the exchange points between different networks.
These Internet Exchange Points(IXPs) are the primary locations where different Internet providers connect in order to provide each other access to traffic originating on their different networks. By having a connection to these high speed and highly interconnected locations, a CDN provider is able to reduce costs and transit times in high speed data delivery.
The Task 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 images stored in S3
- Setting up the Content Delivery Network using Cloud Front and using the origin domain as S3 buckeFinally , place the CloudFront URL on the webapp code for security and low latency
Launch the EC2 Instance
First we have to launch one EC2 instance using the created key-pair and the security group by using following command :
aws ec2 run-instances --image-id <image_Id > --instance-type t2.micro --count 1 --security-group-ids <security_group_Id > --key-name <key_name>
Lets check instances launched or not
So let’s configure this Instance as web server
For configuring the webserver we have to install httpd software by using the command : " yum install httpd "
Now we have to start the service by using the command : systemctl start httpd
Now we have create the EBS volume
aws ec2 create-volume --availability-zone ap-south-1a --size 5
Lets check the volume has been created or not
Now attach this EBS volume to the created instance
Lets check the volume has been attached or not
To Use the Attached Volume , the Volume must be partitioned and formatted :
To create the partition we have to use fdisk /dev/xvdf
Lets check the partition has been created or not
To Format this partition we have to use mkfs.ext4 /dev/xvda1
After formatting we have to mount it on the /var/www/html/ folder
Partition has been successfully formatted !!!
Now create a S3 Bucket to upload an Object :
aws s3api create-bucket --bucket <bucket_name> --region <Region_code> --create-bucket-configurationConstraint = <region_code>
Lets check the bucket has been created or not
Upload an Image as an object in the Bucket :
Lets check an image has been uploaded or not
Now write the code in .html form and give the link of our object in that code
Lets check the code has been working fine or not
Great our code is working good ????????
Now we have to set up Content Delivery Network using CloudFront and using the origin domain as S3 bucket.
Firstly we have to Created a CloudFront Distribution with the origin
Lets check the CloudFront Distribution has been created or not
Finally, we have to place the Cloud Front URL in the code for security and low latency.
And finally check the code has been working fine or not
Yaaaaa Hurryyyy !!!! It's working good !! ??????
Hope you like this article!!
Fronted Developer | System Engineer @TCS
4 年Nice?