Let’s Create High Availability Architecture with AWS CLI and setting up Content Delivery Network for low latency
In this article I’m going to show you how to Create High Availability Architecture with AWS CLI.
🔆Task Description:
◾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 pictures stored in S3
◾Setting up Content Delivery Network using CloudFront and using the origin domain as S3 bucket.
◾Finally place the Cloud Front URL on the webapp code for security and low latency.
✡️First we have to create a key-pair -
command : aws ec2 create-key-pair — key-name <value> — query KeyMaterial > <value>.pem — output text > <value>.pem
Let’s check on AWS Console :
✡️Create a security group -
command : aws ec2 create-security-group — group-name <value> — description <value>
Let’s check on AWS Console :
✡️Now we have to set some inbound rules over AWS Firewall -
We will allow port no. 22 and 80 here :
command:
aws ec2 authorize-security-group-ingress — group-id <value> — group-name <value> — port 22— cidr 0.0.0.0/0 — protocol tcp
aws ec2 authorize-security-group-ingress — group-id <value> — group-name <value> — port 80 — cidr 0.0.0.0/0 — protocol tcp
Let’s check on AWS Console :
✡️Now we have to launch one EC2 Instance to configure the web server -
command : aws ec2 run-instances — image-id <value> — instance-type <value> — count <value> — subnet-id <value> — security-group-ids <value> — key-name <value>
Let’s check on AWS Console :
✡️Now create one EBS VOLUME 0f 1 GB -
command : aws ec2 create-volume — volume-type <value> — size <value> — availability-zone <value>
Let’s check on AWS Console :
✡️Now we have to attach this volume in our EC2 Instance -
command : aws ec2 attach-volume — instance-id <value> — volume-id <value> — device <value>
Let’s check on AWS Console :
✡️Now Install the Apache httpd webserver on the top of AWS -
command : yum install httpd
Let’s see software has been installed or not ?
✡️Now let’s Check how many hard disk we have -
command : fdisk -l
✡️Now let’s create the partition of 1GB volume :
command : fdisk /dev/xvdf
✡️Now we have successfully created our partition :
✡️Now we have to format that partition :
command : mkfs.ext4 /dev/xvdf1
✡️Now mount the Document Root(/var/www/html) folder :
command : mount /dev/xvdf1 /var/www/html
Now check it is mounted or not by this command : df -h
✡️Start the httpd service -
command : systemctl start httpd
And for check the service status : systemctl status httpd
✡️Create S3 bucket to store Static objects used in code such as pictures :
command : aws s3api create-bucket — bucket <value> — region <value> — create-bucket-configuration <value>
Let’s check on AWS Console :
Let’s put one object such as picture on the S3 Bucket :
Check on the AWS Console :
Now we can use this URL in our WEB PAGE :
So now I’m putting this URL in my Web Page :
And here we can see that by using this URL our Output is showing clearly :
✡️Setting up Content Delivery Network using CloudFront and using the origin domain as S3 bucket.
command : aws cloudfront create-distribution —origin-domain-name <value>
Check on AWS Console :
Here we can see our new domain name is given :
Give this Domain name to Web Page :
Let’s run this web page on the top of Web Server :
So Finally we have setting up the Content Delivery Network and place the CloudFront URL in the Web App code for security and low latency. Now our web page become more faster in terms of speed as Image is coming from AWS Cloud.
🔹 !! HAPPY LEARNING !! 🔹
🔹 Keep sharing keep learning 🔹
🔹 Thank You 🔹