🔰 Create High Availability Architecture with AWS CLI 🔰

🔰 Create High Availability Architecture with AWS CLI 🔰

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.

To Perform This Task You should have an aws account and an IAM user .

STEP 1:Download aws CLI and configure it.

No alt text provided for this image

STEP 2: START AN INSTANCE

No alt text provided for this image
No alt text provided for this image
COMMAND : aws ec2 start-instances --instance-ids <ID_OF_YOUR_INSTANCE>
No alt text provided for this image

STEP 3: Create an EBS volume and then attach it to the instance.

No alt text provided for this image
COMMAND TO CREATE AN EBS :
 aws ec2 create volume --availability-zone <AZ_CODE> --size <SIZE> 
No alt text provided for this image

STEP 4 : Now attach the volume to the instance

No alt text provided for this image
COMMAND TO ATTACH AN EBS:
aws ec2 attach-volume --volume-id <VOLUME_ID> --instance-id <INSTANCE_ID> --device <STORAGE_NAME>
No alt text provided for this image

Before using this attached volume , it must be partitioned and formatted first.

( here ssh program is used to login and run the command )

STEP 5 : PARTITIONING :

COMMAND TO CREATE PARTITION:
ssh -i <KeyPair_Name> <USERNAME@IP> sudo fdisk <STORAGE_NAME>
No alt text provided for this image

n ( for new partition)

press enter (it will be first partition only)

press enter (it will be counting the space from initial sector)

w (save the partition and exit)

No alt text provided for this image

STEP 6 : FORMAT the partition with ext4 :

COMMAND : ssh -i <KEY_PAIR_NAME <USERNAME@IP> sudo mkfs.ext4 <PARTITION_NAME> 
No alt text provided for this image

STEP 7 : Now Install httpd server using yum command

COMMAND : ssh -i <KEYPAIRNAME> <USERNAME@IP> sudo yum install httpd -y
No alt text provided for this image

STEP 8 : Start the httpd service:

COMMAND : ssh -i <KEYPAIRNAME> <USERNAME@IP> sudo systemctl start httpd

Check the status of the service:

COMMAND : ssh -i <KEYPAIRNAME> <USERNAME@IP> sudo systemctl status httpd
No alt text provided for this image

STEP 9 : Now , Mount the /var/www/html folder to the created partition of the EBS volume

COMMAND : ssh -i <KEYPAIRNAME> <USERNAME@IP> sudo mount <Partition_name> /var/www/html
No alt text provided for this image

To check the web server configuration create a small code and access it through the webUI

NOTE : save the code in /var/www/html directory.

No alt text provided for this image
No alt text provided for this image

STEP 10 : Create a S3 bucket and upload some objects there.

COMMAND : aws s3api create-bucket --bucket <Bucket_Name> --region <Region_code> --create-bucket-configurationConstraint=<region_code>
No alt text provided for this image
No alt text provided for this image

STEP 11 : Add an image as an object in the bucket.

No alt text provided for this image
No alt text provided for this image

STEP 12 : Now create a cloud Front distribution with the origin as above bucket .

COMMAND : aws cloudfront create-distribution --origin-domain-name <bucket_name>
No alt text provided for this image
No alt text provided for this image

STEP 13: Add the domain name of the cloud front distribution in the html file 

No alt text provided for this image

Now open the web.html page in browser.

No alt text provided for this image
THANKS FOR READING :)














To view or add a comment, sign in

Others also viewed

Explore content categories