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 :
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
Attach EBS to /var/www/html
mount /dev/xvdb /var/www/html
- 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
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
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
Replace the Image Source with CloudFront Domain
img src = "https://...CloudFront..Domain.."
WebPage:
?Done this task under the guidance of Mr.Vimal Daga sir in ARTH
Thanks for Reading!
?
Cloud Technical Solutions Engineer @ Google
4 年Great bro Kethavath Siva Naik ??