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.
Step 1- Webserver configured on EC2 Instance
- Create a key pair
Command- aws ec2 create-key-pair β key-name <key_name>


- Create security group
Command: aws ec2 create-security-group β group-name <sg_name> β description <description_sg>


- Create EC2 instance
Command: aws ec2 run-instances β image-id <imageid> β instance-type <instance-type> β key-name <key-name> β count <number of count> β security-group-ids <sg_id> β subnet-id <subnet_id>


- Configure web server on EC2 instance and to start the service.


Step 2- Document Root(/var/www/html) made persistent by mounting on EBS Block Device.
- Create EBS volume


- Attach EBS volume to EC2 instance

- To check EBS volume is attached successfully or not

- Mount EBS volume

Step3- Static objects used in code such as pictures stored in S3
- Create a bucket


- Upload object to bucket


- Make object and bucket public

Now go to browser and search with Object URL, you will see your object because you make this object public :

STEP 4 - Setting up Content Delivery Network using CloudFront service and using the origin domain as S3 bucket.
- Create the cloudfront distribution using the domain name as S3 bucket :


- Now go to browser and search with domain name(d3ggjevc1qn8gy.cloudfront.net/object_name) provided by the cloudfront distribution, you will see that you will be automatically landed to the object URL with low latency :


STEP 5 - Finally place the Cloud Front URL on the webapp code for security and low latency.
Open /var/www/html/index.html


Thank You!
Keep sharing, keep learning.