Create High Availability Architecture with AWS CLI Using Cloud-Front , S3 and EBS
Step 1 : Launch an EC2 Instance from CLI
aws ec2 run-instances --image-id ami-0e306788ff2473ccb --instance-type t2.micro --count 1 --subnet-id subnet-4d838b25 --security-group-ids sg-09bad2e22a528f1c5 --key-name keyhadoop
Step 2 : Now we have to create EBS volume
aws ec2 create-volume --volume-type gp2 --size 1 --availability-zone ap-south-1a
Step 3 : Attach EBS Volume to EC2 Instance
aws ec2 attach-volume --instance-id i-07b2dc52b69a548fb --volume-id vol-0e5a0b110fc226058 --device /dev/sdf
Step 4 : Now we have to configure webserver for this we have to install httpd
We have to configure webserver in launched instance. We can connect instance directly or by using putty program.
Installing httpd package
yum install httpd
Creating partition :
Now, we have to create partition to make document root/var/www/html.
fdisk /dev/sdf
Formatting partition :
mkfs.ext4 /dev/sdf1
Mounting :
mount /dev/sdf1 /var/www/html/
Step 5 : Now we have to create S3 Bucket from CLI
aws s3api create-bucket --bucket lwarth456 --region ap-south-1 --create-bucket-configuration LocationConstraint=ap-south-1
As our bucket is ready to use. Now we have to upload our data inside bucket.
Now, using the above URL provided to the object by s3, we can now access the image.
Step 6 : Create Cloud-Front Distribution :
aws cloudfront create-distribution --origin-domain-name lwarth456.s3.amazonaws.com
Step 7 : Finally now we create file in EC2 instance and give the image url of Cloud-Front
Thank You:)