Create High Availability Architecture with AWS CLI to Deliver the Static Content

Create High Availability Architecture with AWS CLI to Deliver the Static Content

Hello, Connections! Here is my article about how to Deliver Content quickly.

? Task Description ?

Create the architecture with AWS CLI

  • Configure Web Server on EC2 Instance
  • Create EBS and attach to Document Root to make the Webserver data Persistent
  • Store Static objects like Images and Videos in S3 Bucket
  • Set up Content Delivery Network using Cloud Front and using the origin domain as S3 bucket.
  • Finally, update the Website with Cloud Front URL to deliver the Static Content


CloudFront :

No alt text provided for this image

CloudFront is a content delivery network offered by Amazon Web Services. Content delivery networks provide a globally-distributed network. AWS has multiple Edge Locations to deliver the content to End Users. Cloudfront works like this.

Let's say we have a website and a customer from the Mumbai region accessing the Website. When the customer first sends the request first reach to the nearest edge location, If the request miss then the server in Edge Location gets the static Object from AWS Main Datacenter and maintains the caches for 1 Day. The Client can decide how long the caches to live in Edge locations. Then the Static content is delivered to customers from Edge Locations

For More Information about CloudFront Visit

Launch EC2 Instance, Create Volume and attach the Volume to Document Root :

Attach the Volume to Document Root /var/www/html/

Launch Instance and Do SSH to the Instance Install Httpd Server

yum install httpd -y

systemctl start httpd

systemctl enable httpd

To list all the volumes

lsblk
No alt text provided for this image

Attach EBS to /var/www/html

mount /dev/xvdb  /var/www/html
No alt text provided for this image
  • We have a file index.html and the file have a img tag with Cloudfront URL as the source for an image in Document Root

Create S3 Bucket and Store Image in Bucket

S3 is the Simple Storage Service. S3 is the Object Storage as a Service and we can store static objects in S3

aws s3api create-bucket --bucket arthtask6arth --region ap-south-1 --create-bucket-configuration LocationConstraint=ap-south-1
No alt text provided for this image

The command will create an S3 bucket in ap-south-1 region

Copy the Image to S3 Bucket

The Image logo.png copy to s3 Bucket arthtask6arth

aws s3 cp logo.png s3://arthtask6arth/logo.png

Make the Object in Bucket Public :

The Objects in S3 Bucket is Private and can't be accessed. We have to make the Object Public use in CloudFront

aws s3api put-object-acl --bucket arthtask6arth --key logo.png --acl public-read
No alt text provided for this image
No alt text provided for this image

Setting up Content Delivery Network using CloudFront

The following command will deliver the logo.png Which is in the S3 bucket "arthtask6arth"

aws cloudfront  create-distribution --origin-domain-name arthtask6arth.s3.amazonaws.com --default-root-object logo.png
No alt text provided for this image

Replace the Image Source with CloudFront Domain

No alt text provided for this image
img src = "https://...CloudFront..Domain.."

WebPage:

No alt text provided for this image
?Done this task under the guidance of Mr.Vimal Daga sir in ARTH

Thanks for Reading! 

?


Adarsh Kumar

Cloud Technical Solutions Engineer @ Google

4 年

Great bro Kethavath Siva Naik ??

回复

要查看或添加评论,请登录

Siva Naik Kethavath的更多文章

社区洞察

其他会员也浏览了