π° 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.
STEP:1:Launch an instance and connect a EBS volume
STEP:2:Install Apache webserver on instance
#open root account : sudo su -root
#yum install httpd
#start the service : systemctl start httpd
#check the status of service : systemctl status httpd
STEP:3:Create a partition in attached EBS volume
STEP:3.1:create partition
fdisk <disk name>
here, fdisk /dev/sdg
STEP:3.2:format the partition
mkfs.ext4 <partition name>
mkfs.ext4 /dev/xvdg5
STEP:3.3:mount the partition
mount <partition name> <folder name>
here, mount /dev/xvdg5 /var/www/html/
STEP:4:Create a S3 bucket
STEP:4.1:creating s3 bucket using cli
aws s3api create-bucket β acl public-read-write β bucket <bucketname> β region <region> β create-bucket-configuration LocationConstraint=<region>
STEP:4.2:Upload image to s3 bucket
1.cd /<folder name>
2.aws s3 cp <file name> s3://<bucketname>
3.aws s3api put-object-acl β bucket <bucket name> β key <file name> β acl public-read [to make it public]
STEP:5:Create Cloud Front Distribution
aws cloudfront create-distribution β origin-domain-name <bucket_name>.s3.amazonaws.com
STEP:6:Create html file and add object file to it
STEP:6.1:create html file
1.cd /var/www/html
2.vi <file name>
STEP:6.2:add object file
Url: http://<domain name.cloudfront.net>/file name.html
STEP:7:Visit your webpage
url: http:/<public ip>/<html file name>
β β β β β β β ************************************* β β β β β β β