High availability website with CloudFront

High availability website with CloudFront

You may not have heard the name of CloudFront but surely you should have heard the name of CDN (Content Delivery Network). When you host a website in a place, though the whole world with an internet connection can visit your website, But not all can access your website as fast as the other. This is due to latency in the network. The places which are far from the hosting servers will be slower than the nearer ones. So what CloudFront is a CDN where the static files are cached in servers local to the country or parts of the country with the help of AWS edge locations which are small datacenters located. Thanks to Vimal Daga sir, in this article, I am going to create a high availability infrastructure with AWS CLI interface

Create an S3 bucket

we can create s3 bucket using the command:

aws s3 mb s3://smclibucket --region ap-south-1
No alt text provided for this image

Copy images to s3 bucket

To copy, AWS provides cp subcommand. But we also need to make sure that public read should be active for anyone on the internet can browse it

 aws s3 cp --acl public-read awsclicover.jpg s3://smcclibucket/awsclicover.jpg
No alt text provided for this image

Create CloudFront and connect to S3

we create a CDN using the below command

aws cloudfront create-distribution --origin-domain-name smcclibucket.s3.amazonaws.com
No alt text provided for this image

This is the output we get after using the url domain name given in the JSON output

No alt text provided for this image


Creating ec2 instance

To create AWS EC2 instance, I have written a detailed blog. check this link for more information.

aws ec2 run-instances --image-id ami-0e306788ff2473ccb --instance-type t2.micro  --count 1 --subnet-id subnet-08f36788b8dbb4452 --security-group-ids sg-040c0a171e0c5ec03 --key-name gpkey
No alt text provided for this image

Creating EBS Volume

aws ec2 create-volume --size 1 --availability-zone ap-south-1a
No alt text provided for this image

Attaching EBS Volume to instance

aws ec2 attach-volume --device /dev/sdb --instance-id i-0d394b94058283eb9 --volume-id vol-0a121c402765aef17
No alt text provided for this image

starting a webserver

first we need to mount the disk. For this we can just format the volume and then create a new partition table and mount it to /var/www/html folder

No alt text provided for this image

Then install httpd server and the index.html file that we want to display. After doing this, we get the output with cloudfront URL being used

No alt text provided for this image

Thanks for reading the article and hope you liked this article




To view or add a comment, sign in

More articles by Sri Meher Chaitanya Varma Nadimpalli

  • Run python on Docker Container

    Python is one of the greatest languages that is being used recently for various applications. But for sure you may need…

  • Elasticity in Hadoop data node with LVM

    when you are working with Hadoop that means you are working with BigData. As the name says, you may run out of storage…

    1 Comment
  • Resize static partition without losing data

    If you work more with Linux or any operating system, you will know how crucial partitioning is. You may create a…

  • Configure Apache Httpd Program in Docker

    We all need a solution to provide our app to users through the web. But we need software that can do that.

  • 🤩One menu to operate everything🤩

    Some may be good at coding and operating CLI tools. But to be good at this, we need to go through a lot of practice to…

  • Most of the famous MNC's use Machine Learning

    We all know that machine learning has a lot of use cases. From facial recognition in Facebook to auto-complete in…

  • CLI interface in AWS Cloud

    You may be using cloud services for testing or running your infrastructure in the cloud. But when you need to automate…

  • My journey of learning ansible automation

    Ansible is one of the amazing tools I have ever used. Thought I used to do automation with the help of python and shell…

  • Companies Like OLX uses AWS for their architecture

    Olx is one of the greatest and biggest classified marketplaces and an online platform where a buyer meets the seller…

  • How Companies manage Big Data

    With the growth of your application or services, your data also increases parallelly and when you reach a position…

Others also viewed

Explore content categories