Task Description :

Create High Availability Architecture with AWS CLI.

The architecture includes-

i) Webserver configured on EC2 Instance

ii) Document Root(/var/www/html) made persistent by mounting on EBS Block Device.

iii) Static objects used in code such as pictures stored in S3

iv) Setting up Content Delivery Network using CloudFront and using the origin domain as S3 bucket.

v)Finally place the Cloud Front URL on the webapp code for security and low latency.

Now, starting with the solution part, firstly we need to launching an EC2 instance


aws ec2 run-instances --image-id <your-image-id> --instance-type <instance-type> --security-group-ids <your-security-group-id> --subnet-id <subnet-id> --key-name <key-name>

We will then create an EBS volume


aws ec2 create-volume --availability-zone <availability-zone> --size 1 --volume-type <volume-type>

And attach the same volume to the instance


aws ec2 attach-volume --device xvdh --instance-id <your-instance-id> --volume-id <your-volume-id>

Now we will create partition of 100MB in the attached volume.

And after creating partition we need to format the partition and install httpd using yum command.

Now lastly we need to mount the/var/www/html folder to the created partition.

We will now need to create a bucket in S3 and upload a file there and will use cloud front and provide the link of the file in S3 to be accessed.

aws cloudfront create-distribution --origin-domain-name divyakurothe.s3.amazonaws.com --default-root-object 60258.jpg

Now we will create cloudfront distribution and provide the object url.

Devops Enthusiast