High Availability Architecture with AWS CLI..!!
High Availability Architecture with AWS means software solutions offer data protection and with low latency as well as reliable performance with minimal downtime and costs. The Services s3 and CloudFront given by AWS helps in getting high availability architecture. This can be well explained by the given diagram.
The 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 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.
STEP-1: Webserver configured on EC2 Instance
For Configuring the Web Server We have to first launch an EC2 instance using CLI. For that first creating the Key using command aws create-key-pair --key-name os1_key_cli.
For Checking we can check in AWS account that os1_key_cli is created successfully..!!
After that For configuring web server an instance is launched using CLI. Using command aws ec2 run-instances --image-id ami-0e306788ff2473ccb --instance-type t2.micro --count 1 --security-group-ids sg-0abc587e11c82be9a --key-name os1_key_cli
Instance Launched Successfully..!!
In that Instance Configuring web server. But for configuring we require httpd so for that use yum install httpd and to start the service use systemctl start httpd and for checking use command systemctl status httpd.
Here it is seen that status is active this means the web server is configured successfully..!!
STEP-2: Document Root(/var/www/html) made persistent by mounting on EBS Block Device.
Before Mounting this /var/www/html, first Create EBS Volume using command and attaching it to the instance and finally after that doing partition and mounting to the root.
To create the volume Use command aws create-volume --availability-zone ap-south-1a --size 1 --volume-type gp2 and checking in the aws account that it is successfully created.
For attaching use command aws ec2 attach-volume --volume-id volume_id --instance-id instance_id --device /dev/sdf.
For creating Partition use command fdisk /dev/xvdf.
For Formatting use command mkfs.ext4 /dev/xvdf1.
For mounting Use command mount /dev/xvdf1 /var/www/html and to check that it is mounted successfully or not use df -h command.
STEP-3: Static objects used in code such as pictures stored in S3.
For creating static objects so First we have to create a bucket and after that uploading the object into the bucket. To create bucket use command: aws s3api create-bucket --bucket bucket_name --region ap-south-1 --acl public-read --create-bucket-configuration LocationConstraint=ap-south-1
Through this it can be checked that bucket named cloudfrontwebserver2001 is created successfully. Now putting the object in the bucket for that we have to provide the path, the command used is aws s3 cp C:\Users\shris\Desktop\sk\cloudfront.jpg s3://cloudfrontwebserver2001 --acl public-read
To verify that object is uploaded we check and it is connected successfully.
STEP-4: Setting up Content Delivery Network using CloudFront and using the origin domain as S3 bucket.
First Creating the clod-front distribution for S3 bucket objects. So for this command used is aws cloudfront create-distribution --origin-domain-name d12cey3ftuwc7p.cloudfront.net
Cloud Front Distribution created Successfully.
Through this it is confirmed that CloudFront Distribution is created successfully.
STEP-5: Finally place the Cloud Front URL on the webapp code for security and low latency.
Now in the instance in the html file we will provide the CloudFront URL which help in security and reduce latency. So for going inside html file use vi file_name.html and inside that providing the CloudFront URL.
Now Finally Client can easily access the web page using public IP with low latency and with a high speed.
So Through this We can say that these services like S3 and CloudFront with their architecture helps in getting the user to access easily and effectively with high speed and low latency..!!
Great 👍
Well done!!
Great work!!!