Tuesday, March 23, 2021

ARTH - Task 6

 Task Description

>> Create High Availability Architecture with AWS CLI 

>> The architecture includes -

- Web server 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.

Step1: Download the Aws_cli

https://aws.amazon.com/cli/

https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-windows.html


Step 2: Install the aws_cli and setting_up the
env_variable








SET THE ENV PATH FOR AWS_CLI






To download the packages inside the directory use “terraform init

Step 3: configuring the aws_cli


AFTER SUCCESSFULLY COMPLETE THE ABOVE PRACTICAL NOW CREATE A USER IN
AWS AND CONFIGURE THE AWS CLI USING “aws configure” and further passing the
secret key,access-key ,zone and format as(‘json’)













C:\Users\user>cd Desktop/cloud
C:\Users\user>aws ec2 create-key-pair --key-name mykey1111






C:\Users\user>aws ec2 create-security-group --group-name MySecurityGroup
--description "My security group" --vpc-id vpc-028b6e67c7a953d6d
{
"GroupId": "sg-0575c309c404208e6"
}




C:\Users\user>aws ec2 authorize-security-group-ingress --group-id
sg-0575c309c404208e6 --group-name MySecurityGroup --protocol tcp --port 22
--cidr 0.0.0.0/0




C:\Users\user\Desktop\cloud>aws ec2 run-instances --image-id
ami-0447a12f28fddb066 --instance-type t2.micro --count 1 --subnet-id
subnet-d7ead0bf --security-group-ids sg-08ede0983c0034902 --key-name
mykey1111
{
"Groups": [],
"Instances": [
{
"AmiLaunchIndex": 0,
"ImageId": "ami-0447a12f28fddb066",
"InstanceId": "i-04631b57139072206",
"InstanceType": "t2.micro",
"KeyName": "mykey1111",
"LaunchTime": "2020-06-01T21:31:37+00:00",
"Monitoring": {
"State": "disabled"
},
"Placement": {
"AvailabilityZone": "ap-south-1a",
"GroupName": "","Tenancy": "default"
},
"PrivateDnsName": "ip-172-31-40-7.ap-south-1.compute.internal",
"PrivateIpAddress": "172.31.40.7",
"ProductCodes": [],
"PublicDnsName": "",
"State": {
"Code": 0,
"Name": "pending"
},
"StateTransitionReason": "",
"SubnetId": "subnet-d7ead0bf",
"VpcId": "vpc-15f8e57d",
"Architecture": "x86_64",
"BlockDeviceMappings": [],
"ClientToken": "49daca14-b0ef-4e35-ab24-536e5527d2ae",
"EbsOptimized": false,
"Hypervisor": "xen",
"NetworkInterfaces": [
{
"Attachment": {
"AttachTime": "2020-06-01T21:31:37+00:00",
"AttachmentId": "eni-attach-00bf4144bdf312034",
"DeleteOnTermination": true,
"DeviceIndex": 0,
"Status": "attaching"
},
"Description": "",
"Groups": [
{
"GroupName": "launch-wizard-1",
"GroupId": "sg-08ede0983c0034902"
}
],
"Ipv6Addresses": [],
"MacAddress": "02:18:87:f7:6a:fc",
"NetworkInterfaceId": "eni-0009f73471ec18b1e",
"OwnerId": "410914255776",
"PrivateDnsName": "ip-172-31-40-7.ap-south-1.compute.internal",
"PrivateIpAddress": "172.31.40.7","PrivateIpAddresses": [
{
"Primary": true,
"PrivateDnsName": "ip-172-31-40-7.ap-south-1.compute.internal",
"PrivateIpAddress": "172.31.40.7"
}
],
"SourceDestCheck": true,
"Status": "in-use",
"SubnetId": "subnet-d7ead0bf",
"VpcId": "vpc-15f8e57d",
"InterfaceType": "interface"
}
],
"RootDeviceName": "/dev/xvda",
"RootDeviceType": "ebs",
"SecurityGroups": [
{
"GroupName": "launch-wizard-1",
"GroupId": "sg-08ede0983c0034902"
}
],
"SourceDestCheck": true,
"StateReason": {
"Code": "pending",
"Message": "pending"
},
"VirtualizationType": "hvm",
"CpuOptions": {
"CoreCount": 1,
"ThreadsPerCore": 1
},
"CapacityReservationSpecification": {
"CapacityReservationPreference": "open"
},
"MetadataOptions": {
"State": "pending",
"HttpTokens": "optional",
"HttpPutResponseHopLimit": 1,
"HttpEndpoint": "enabled"}
}
],
"OwnerId": "410914255776",
"ReservationId": "r-06cad74b9a0efc348"
}
C:\Users\user>aws s3api create-bucket --bucket avi12345678 --region ap-south-1
--create-bucket-configuration LocationConstraint=ap-south-1
{
"Location": "http://avi12345678.s3.amazonaws.com/"
}


C:\Users\user\Desktop\cloud>ssh -l ec2-user 13.235.24.83 -i mykey1111.pem
The authenticity of host '13.235.24.83 (13.235.24.83)' can't be established.
ECDSA key fingerprint is
SHA256:AiIuVm0N9gv+phh9lashkjsbUHTW/wY5Hu/lDRDcLNQ.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '13.235.24.83' (ECDSA) to the list of known hosts.
__| __|_ )_| ( / Amazon Linux 2 AMI
___|\___|___|
https://aws.amazon.com/amazon-linux-2/
[ec2-user@ip-172-31-40-7 ~]$ whoami
ec2-user
[ec2-user@ip-172-31-40-7 ~]$ sudo su - root
[root@ip-172-31-40-7 ~]# fdisk -l
Disk /dev/xvda: 8 GiB, 8589934592 bytes, 16777216 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 0D7E094F-1C63-43F2-AC82-3316E992075B
Device
Start
End Sectors Size Type
/dev/xvda1 4096 16777182 16773087 8G Linux filesystem
/dev/xvda128 2048 4095 2048 1M BIOS boot
Partition table entries are not in disk order.
Disk /dev/xvdf: 1 GiB, 1073741824 bytes, 2097152 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
[root@ip-172-31-40-7 ~]# fdisk /dev/xvdf
Welcome to fdisk (util-linux 2.30.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x427d49e5.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): pPartition number (1-4, default 1):
First sector (2048-2097151, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-2097151, default 2097151):
Created a new partition 1 of type 'Linux' and of size 1023 MiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
[root@ip-172-31-40-7 ~]# mkfs.ext4 /dev/xvdf1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 261888 blocks
13094 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
[root@ip-172-31-40-7 ~]# mount /dev/xvdf1 /var/www/html




No comments:

Post a Comment

Hadoop WebApp Automation

  Abstract : Today is an era of Technology and with the increase of technology the amount of data it produces increases every second even no...