HIGH AVAILABILITY ARCHITECTURE WITH AWS CLI

So lets begin this task !!

Pre-requisites:

1. Install and Configure AWS CLI version 2.

2. Create AWS IAM User.

Step 1

# run only once and enter the details
aws configure

Step 2

aws ec2 create-key-pair --key-name awscsakey --query "keyMaterial" > awscsakey.pem

Step 3

aws ec2 create-security-group --description Security_group_using_AWS_CLI --group-name SecurityGroupForCLI

Step 4

aws ec2 authorize-security-group-ingress --group-id sg-0d489a16b56da793e --protocol  all --cidr 0.0.0.0/0

Step 5

aws ec2 run-instances --image-id ami-052c08d70def0ac62 --security-group-ids sg-0d489a16b56da793e --instance-type t2.micro --subnet-id subnet-6b1b7027 --key-name awscsakey

Step 6

aws ec2 create-volume --availability-zone ap-south-1b --size 1 --volume-type gp2

Step 6

aws ec2 attach-volume  --instance-id i-0e898efb2e8844ce4  --volume-id vol-0cb41c3d139b8a9a8  --device /dev/xvdh

Great! 👏 you have created EC2 instance, EBS Volume and successfully attach them together.

Now we are going to setup Cloud Front for Content Delivery Network.

Step 7

# Change the permission of private key file.
chmod 400 awscsakey.pem
# SSH to EC2 instance using Private Key.
ssh -i "awscsakey.pem" ec2-user@ec2-13-232-153-64.ap-south-1.compute.amazonaws.com

Step 8

# command to check the partitions available in the instances
fdisk -l
mkfs.ext4 /dev/xvdh
# command to start partition process
fdisk /dev/xvdh# write the following options
# select p to the the details of the partitions available

p# select n to create a new partition
n# select p for the primary or e for extended partition
p# Select the number of partitions 1-4
1# Starting of the first sector, starting from 2048 as a default.
Press Enter without any changes# Ending of the sector, ending at 2097151 as default(entire size)
Press Enter without any changes# Press p to see the details of the partition
p
# command to check the partitions available in the instances
fdisk -l
mkfs.ext4 /dev/xvdh1

Step 9

dnf install httpd
systemctl status httpd

Step 10

mount /dev/xvdh1 /var/www/html

Step 11

aws s3api  create-bucket  --bucket arth-task-6-1523  --region ap-south-1   --create-bucket-configuration LocationConstraint=ap-south-1

Step 12

# change to root user
sudo su
cd /var/www/htmlvi
index.html
# copy the code
# press esc

:wq# press enter
# restart the server
systemctl restart httpd
# html code
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
.fa {
padding: 20px;
font-size: 30px;
width: 30px;
text-align: center;
text-decoration: none;
margin: 5px 2px;
border-radius: 50%;
}.fa:hover {
opacity: 0.4;
}
.fa-github {
background: #24292E;
color: white;
}
.fa-linkedin {
background: #007bb5;
color: white;
}
.fa-instagram {
background: #125688;
color: white;
}
.fa-medium {
background: #117A65;
color: white;
}
.fa-rss {
background: #808080;
color: black;
}img {
border-radius: 50%;
}
.a {
opacity: 0.9
background: #808080;
}
</style>
</head>
&nbsp
<p>
<body bgcolor="white" class=a>
<center><img src="http://d20poq3ti3l95r.cloudfront.net/TechBoutique.jpg" alt="Sami" style="width:200px">
<h2><font face = "Verdana" size = "6">TechBoutique Automation Hub</font></h2>
<h4><font face = "Verdana" size = "4">Blogger || Arth Learner || Developer </font></h4>
</center>

</body>
</body>
</html>

Step 13

aws cloudfront create-distribution  --origin-domain-name  arth-task-6-1523.s3.amazonaws.com

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store