Creating High Availability Architecture with AWS CLI

Tirth Patel
3 min readOct 31, 2020

--

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 images 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 create an EC2 instance, along with security group, key-value pair and attaching EBS block, go through below article. After attaching EBS Volume, we need to mount it on the Document Root i.e /var/www/html

Now that we have attached EBS, we need to download httpd software.

To download httpd : yum install httpd

To use attach EBS volume, we need to Partition, Format and Mount to document root.

Creating Partition in EBS Volume

Format partition created with command : mkfs.ext4 /dev/xvdf

Finally, mount to the document root with mount /dev/xvdf /var/www/html

Now create a S3 bucket and upload data, commands are in below image.

Before moving forward, we need to make the object public.

Make object public

Now that we have a object URL we can create a simple html webpage having image source from S3 bucket.

Now, disable SELinux with setenforce 0 and start web server service with command : systemctl start httpd.

We can check with putting the URL in browser, <ip_address>/index.html

Now, create a Cloud Front so that all the clients from different areas of the world can have easy access of data with Lower latency and high speed content delivery with better data security.

Using below command to create a Cloud Front distribution:

aws cloudfront create-distribution — origin-domain-name setupcdnaws.s3.amazonaws.com

So this will create a Cloud Front Distribution with origin as “setupcdnaws”.

Now that we have Cloud Front URL, we can put it in initial webpage for easy access, lower latency and high security.

URL format : <domain name>/<object name>

Restart the httpd services and check your webpage again.

Thus, we have successfully created a High Availability Architecture with AWSCLI.

--

--

No responses yet