Create High Availability Architecture With AWS CLI

Create High Availability Architecture With AWS CLI

Heloo Everyone Myself Dhwanil Gangani, Will Show You Some Interesting Things In these Article And Also It Will Help You To Boost Your Knowledge Regarding "How To Create High Availability Architecture With AWS CLI".

So Be With Me Till End of These Article. So Let's Start The Small Journey :

#Vimal Sir Has Given Us A Task Which Is Describe Below :

---------------------------------------------------------------------------------------------

**** TASK DESCRIPTION – AWS ****

* Task 6 : 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 Cloud Front and using the origin domain as S3 bucket.

~ Finally place the Cloud Front URL on the webapp code for security and low latency.

*All the above steps must be performed using CLI

No alt text provided for this image

---------------------------------------------------------------------------------------------

* What Is AWS Cloud Front ?

No alt text provided for this image

Cloud Front is a CDN (Content Delivery Network). It retrieves data from Amazon S3 bucket and distributes it to multiple datacenter locations. It delivers the data through a network of data centers called edge locations.

Amazon Cloud Front is a web service that speeds up distribution of your static and dynamic web content, such as .html, .css, .js, and image files, to your users. Cloud Front delivers your content through a worldwide network of data centers called edge locations.

When a user requests content that you're serving with Cloud Front, the user is routed to the edge location that provides the lowest latency (time delay), so that content is delivered with the best possible performance.

  • If the content is already in the edge location with the lowest latency, Cloud Front delivers it immediately.
  • If the content is not in that edge location, Cloud Front retrieves it from an origin that you've definedsuch as an Amazon S3 bucket that you have identified as the source of origin.

---------------------------------------------------------------------------------------------

* So let's Start The Journey Of Creating High Availability Architecture With AWS CLI :

---------------------------------------------------------------------------------------------

* Some Pre - Requisite To do these practical is :

Step 1 :- First launch an ec2 instance in particular zone.

Step 2 :- Then Create a 1Gb "EBS Volume" in same Zone where Instance Is Launched.

Step 3 :- Then Attach That Volume of 1Gb to that Ec2 Instance.

Note :- These 3 Step Process is Describe In more Detail way in My One of Article whose Link Is given Below. Plz refer it if you don't Know the above 3 Steps. There I have cover all things in detail with CLI CMDs.

---------------------------------------------------------------------------------------------

Step 4 :- Webserver configured on EC2 Instance

To Configure Web Server First we need check if Webserver is installed or not for that CMD is : "rpm -q httpd".

After that if it is not Installed then to Install we use CMD is : "yum install httpd"

No alt text provided for this image
No alt text provided for this image

After That we Need to Start Web Server for that CMD is : "systemctl start httpd"

To Make Webserver Running Permanently CMD is : "systemctl enable httpd"

Run Above CMD after installing httpd. That's It Your Web Server is Configured. Well Done.

---------------------------------------------------------------------------------------------

Step 5 :- Do Partioning, Formatting & Mounting this EBS VOLUME To Document Root(/var/www/html) Directory.

Step 1 : First we need to Create Partitions of That EBS which we Attached to EC2 Instance.

Step 2 : Second we Need to Format That Partition.

Note :- To make Storage Device useable or to store data we need too first make partitions and then format then mount. Here Step 1 & Step 2 is described more in detail in these Article. The Link is given below just refer it :

Step 3 : Know its Time to Mount, But wait here we have to mount that partition with Document Root(/var/www/html). For that CMD is :

"mount /dev/xvdf1 /var/www/html"

No alt text provided for this image

See here we mounted the partition "xvdf1" with document root "/var/www/html".

So here Step 5 is Completed.

---------------------------------------------------------------------------------------------

Step 6 :- Create a S3 Bucket With a Unique Name In The Region

Know First we Require to Create a S3 Bucket Using CLI. S3 bucket you can create in any region but more feasible it to check your nearest region where you can create.

The Use Case to create S3 Bucket is there we will store our image file which will be treated as origin source for cloud front. Also You use any Storage Device as Origin Source. But here we Choose S3 Bucket.

CMD to Create S3 Bucket we Don't Know So here we will take help from AWS CLI Help Option. From here we will get help for Creating a CMD for S3 Bucket.

No alt text provided for this image

Know after going deep dive I have found one CMD to create S3 bucket :

C:\Users\kdhwa>aws s3api create-bucket --bucket aws-arth-cli-bucket-101 --region us-east-1

{

"Location": "/aws-arth-cli-bucket-101"

}

Here We Created S3 Bucket Successfully!

---------------------------------------------------------------------------------------------

Step 7 :- Static Objects Used in Code such as Pictures Stored in S3 Bucket

After that we need to save our image file in S3 Bucket it means we need to Upload The File in S3 Bucket. For That CMD is :

C:\Users\kdhwa\Downloads>aws s3 cp arthpic.jpg s3://aws-arth-cli-bucket-101/arth-images-task6/

upload: .\arthpic.jpg to s3://aws-arth-cli-bucket-101/arth-images-task6/arthpic.jpg

No alt text provided for this image

Here "arthpic.jpg" is the image file which we want to upload.

Note :- Make sure the image is in same location "C:\Users\kdhwa\Downloads" where are you. Here my Image File is in Downloads.

Here "S3://aws-arth-cli-bucket-101/arth-images-task6/" this is the location where we want to save it.

We have Uploaded Static Image Successfully!

No alt text provided for this image

But here we need to make that Image File Public so anyone from outside can access that image file. Default it is Private and because of that any other user can't access that file. So to make it Public CMD is :

C:\Users\kdhwa\Downloads>aws s3api put-object-acl --bucket aws-arth-cli-bucket-101 --key arth-images-task6/arthpic.jpg --acl public-read

Here "--acl" is option used to give permission to the image file. we are giving "public read" permission.

These is Our Origin Location were have Image file Stored.

So we have completed S3 Bucket Part know Let's Create Cloud Front.

---------------------------------------------------------------------------------------------

Step 8 :- Setting up Content Delivery Network using Cloud Front and using the origin domain as S3 bucket

To Setup CDN using Cloud Front & Origin Domain as S3 Bucket we have CMD for that using that our Cloud Front Distribution will be Setup.

Before That we require "Origin Location" where the image is stored. That We get from S3 Bucket. Also we need to give origin path to it that we can get from "Key" of S3 Bucket.

CMD to Setup Cloud Front is :

C:\Users\kdhwa\Downloads>aws cloudfront create-distribution --origin-domain-name aws-arth-cli-bucket-101.s3.amazonaws.com --default-root-object arth-images-task6/arthpic.jpg

{

  "Location": "https://cloudfront.amazonaws.com/2020-05-31/distribution/E1UOCEX94EDT9J",

  "ETag": "E3C2ETPSR27FIZ",

  "Distribution": {

    "Id": "E1UOCEX94EDT9J",

    "ARN": "arn:aws:cloudfront::015153444493:distribution/E1UOCEX94EDT9J",

    "Status": "InProgress",

    "LastModifiedTime": "2020-10-29T13:14:31.090000+00:00",

    "InProgressInvalidationBatches": 0,

    "DomainName": "d11jfe69ioxb7e.cloudfront.net",

    "ActiveTrustedSigners": {

      "Enabled": false,

      "Quantity": 0

    },

    "DistributionConfig": {

      "CallerReference": "cli-1603977268-182445",

      "Aliases": {

        "Quantity": 0

      },

      "DefaultRootObject": "arth-images-task6/arthpic.jpg",

      "Origins": {

        "Quantity": 1,

        "Items": [

          {

            "Id": "aws-arth-cli-bucket-101.s3.amazonaws.com-1603977268-939413",

            "DomainName": "aws-arth-cli-bucket-101.s3.amazonaws.com",

            "OriginPath": "",

            "CustomHeaders": {

              "Quantity": 0

            },

            "S3OriginConfig": {

              "OriginAccessIdentity": ""

            },

            "ConnectionAttempts": 3,

            "ConnectionTimeout": 10

          }

        ]

      },

      "OriginGroups": {

        "Quantity": 0

      },

      "DefaultCacheBehavior": {

        "TargetOriginId": "aws-arth-cli-bucket-101.s3.amazonaws.com-1603977268-939413",

        "TrustedSigners": {

          "Enabled": false,

          "Quantity": 0

        },

        "ViewerProtocolPolicy": "allow-all",

        "AllowedMethods": {

          "Quantity": 2,

          "Items": [

            "HEAD",

            "GET"

          ],

          "CachedMethods": {

            "Quantity": 2,

            "Items": [

              "HEAD",

              "GET"

            ]

          }

        },

        "SmoothStreaming": false,

        "Compress": false,

        "LambdaFunctionAssociations": {

          "Quantity": 0

        },

        "FieldLevelEncryptionId": "",

        "ForwardedValues": {

          "QueryString": false,

          "Cookies": {

            "Forward": "none"

          },

          "Headers": {

            "Quantity": 0

          },

          "QueryStringCacheKeys": {

            "Quantity": 0

          }

        },

        "MinTTL": 0,

        "DefaultTTL": 86400,

        "MaxTTL": 31536000

      },

      "CacheBehaviors": {

        "Quantity": 0

      },

      "CustomErrorResponses": {

        "Quantity": 0

      },

      "Comment": "",

      "Logging": {

        "Enabled": false,

        "IncludeCookies": false,

        "Bucket": "",

        "Prefix": ""

      },

      "PriceClass": "PriceClass_All",

      "Enabled": true,

      "ViewerCertificate": {

        "CloudFrontDefaultCertificate": true,

        "MinimumProtocolVersion": "TLSv1",

        "CertificateSource": "cloudfront"

      },

      "Restrictions": {

        "GeoRestriction": {

          "RestrictionType": "none",

          "Quantity": 0

        }

      },

      "WebACLId": "",

      "HttpVersion": "http2",

      "IsIPV6Enabled": true

    }

  }

}

No alt text provided for this image
No alt text provided for this image

Here we have Created The Cloud Front Distribution. It may take some time because it goes to all 250 Edge Location & Update Image File from Origin Location.

After That We need to copy These  "DomainName: d11jfe69ioxb7e.cloudfront.net" from these cloud front & Origin Path to our Web Page where we are using these Image.

Cloud Front Created Successfully!

---------------------------------------------------------------------------------------------

Step 8 :- Finally place the Cloud Front URL on the webapp code for security and low latency.

Know we need to create small web page where we will put these Cloud Front URL for Security & Low Latency Purpose.

I already have some basic code written with me, It also contains the Cloud Front URL. So here it is :

No alt text provided for this image

Know if anyone Hit to your site then the image will be coming from the clients nearest Edge Location from that Client will get Image Faster means No Latency Problem And It will Create Good User Experience.

If in some region there is no one who have access this website then any client come and visit that site then it might face some Latency Issue or Delay in Opening of Image.

It is because of first time cloud front goes to Origin Location from there it store that image as cache in nearest edge location of that client. Know if second time from that region anyone access that Image it will provide it from edge location. Means Latency issue Solved.

No alt text provided for this image

This URL is intelligent enough to create caches in the client nearest edge location accross the Globe.

No alt text provided for this image

Now Client Can Access The Site & Only First Time Client Faces Miss {high latency} , But After That Client Faces Hits {low latency} Within the TTL[time to leave] .

---------------------------------------------------------------------------------------------

**** I have Completed this task under the guidance of Mr. Vimal Daga sir in the training – ARTH-The School Of Technologies-2020. *****

**** That's All From My Side ****

---------------------------------------------------------------------------------------------

*** Thank You Everyone ***

---------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------


要查看或添加评论,请登录

Dhwanil Gangani的更多文章

  • K-Means Clustering Use Case on Security Domain

    K-Means Clustering Use Case on Security Domain

    ?? In this Article we will Learn : ?? What do you mean by Unsupervised learning? ?? What is K-Means Clustering? ?? How…

  • Industry Use Case of Azure Kubernetes Service(AKS)

    Industry Use Case of Azure Kubernetes Service(AKS)

    ?? In this Article we come to know about : ?? What is AKS? ?? Introduction about Kubernetes(k8s)? ?? More About AKS ??…

    2 条评论
  • About JavaScript & Industry Usecase

    About JavaScript & Industry Usecase

    ?? In this Blog we will Learn : ?? Introduction to JavaScript ?? Why do we Need JavaScript? ?? What can you do with…

    1 条评论
  • Confusion Matrix & Cyber Crimes

    Confusion Matrix & Cyber Crimes

    ?? First of all Let us Understand What is Confusion Matrix in Machine Learning. "Information is the oxygen of the…

    2 条评论
  • Integrate WordPress with AWS RDS

    Integrate WordPress with AWS RDS

    ?? In this article we are going to deploy "WordPress" which is a free and open-source content management system written…

    2 条评论
  • AI?? on AWS ? Practical Workshop

    AI?? on AWS ? Practical Workshop

    ?? AWS Cloud is CSP(Cloud Service Provider) who use to Provide Fully Managed Services that makes Industry To Grow…

    2 条评论
  • Neural Network & Its Industry Usecase

    Neural Network & Its Industry Usecase

    ?? In this Blog we will Learn : ?? What is Neural Networks? ?? Abilities of Neural Network~! ?? Need of Neural Network?…

    2 条评论
  • Kubernetes (K8s)

    Kubernetes (K8s)

    What is Kubernetes ? Kubernetes, also known as K8s, is an open-source system for automating deployment, scaling, and…

  • Ansible Use Cases & Case Study

    Ansible Use Cases & Case Study

    Automation plays an important role in IT industry. Automation is a broad term that can cover many areas of technology…

    2 条评论
  • ??Docker Task 7.2??

    ??Docker Task 7.2??

    Heloo Everyone Myself Dhwanil Gangani, Will Show You Some Interesting Things In these Article And Also It Will Help You…

    4 条评论

社区洞察

其他会员也浏览了