Creating High Availability Architecture with AWS CLI
✔Task Description
🔰 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 BlockDevice
♦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.
Introduction:-
AWS CLI:-
AWS Command Line Interface(AWS CLI) is a unified tool using which, you can manage and monitor all your AWS services from a terminal session on your client.
Although most AWS services can be managed through the AWS Management Console or via the APIs, there is a third way that can be very useful: the Command Line Interface (AWS CLI). AWS has made it possible for Linux, MacOS, and Windows users to manage the main aws services from a local terminal session’s command line. So, with a single step installation and minimal configuration, you can start using all of the functionalities provided by the aws management console using the terminal program. That would be:
AWS EC2:-
Amazon Elastic Compute Cloud is a part of Amazon.com’s cloud-computing platform, Amazon Web Services, that allows users to rent virtual computers on which to run their own computer applications.
AWS EBS:-
Amazon Elastic Block Store (EBS) is an easy to use, high performance block storage service designed for use with Amazon Elastic Compute Cloud (EC2) for both throughput and transaction intensive workloads at any scale. A broad range of workloads, such as relational and non-relational databases, enterprise applications, containerized applications, big data analytics engines, file systems, and media workflows are widely deployed on Amazon EBS.
You can choose from five different volume types to balance optimal price and performance. You can achieve single digit-millisecond latency for high performance database workloads such as SAP HANA or gigabyte per second throughput for large, sequential workloads such as Hadoop. You can change volume types, tune performance, or increase volume size without disrupting your critical applications, so you have cost-effective storage when you need it.
Designed for mission-critical systems, EBS volumes are replicated within an Availability Zone (AZ) and can easily scale to petabytes of data. Also, you can use EBS Snapshots with automated lifecycle policies to back up your volumes in Amazon S3, while ensuring geographic protection of your data and business continuity.
AWS S3:-
Amazon Simple Storage Service is storage for the Internet. It is designed to make web-scale computing easier for developers.
Amazon S3 has a simple web services interface that you can use to store and retrieve any amount of data, at any time, from anywhere on the web. It gives any developer access to the same highly scalable, reliable, fast, inexpensive data storage infrastructure that Amazon uses to run its own global network of web sites. The service aims to maximize benefits of scale and to pass those benefits on to developers.
This guide explains the core concepts of Amazon S3, such as buckets, access points, and objects, and how to work with these resources using the Amazon S3 application programming interface (API).
AWS CloudFront:-
Amazon CloudFront is a fast content delivery network (CDN) service that securely delivers data, videos, applications, and APIs to customers globally with low latency, high transfer speeds, all within a developer-friendly environment. CloudFront is integrated with AWS — both physical locations that are directly connected to the AWS global infrastructure, as well as other AWS services. CloudFront works seamlessly with services including AWS Shield for DDoS mitigation, Amazon S3, Elastic Load Balancing or Amazon EC2 as origins for your applications, and Lambda@Edge to run custom code closer to customers’ users and to customize the user experience. Lastly, if you use AWS origins such as Amazon S3, Amazon EC2 or Elastic Load Balancing, you don’t pay for any data transferred between these services and CloudFront.
You can get started with the Content Delivery Network in minutes, using the same AWS tools that you’re already familiar with: APIs, AWS Management Console, AWS CloudFormation, CLIs, and SDKs. Amazon’s CDN offers a simple, pay-as-you-go pricing model with no upfront fees or required long-term contracts, and support for the CDN is included in your existing AWS Support subscription.
Webserver :-
The term web server can refer to hardware or software, or both of them working together.
- On the hardware side, a web server is a computer that stores web server software and a website’s component files. (for example, HTML documents, images, CSS stylesheets, and JavaScript files) A web server connects to the Internet and supports physical data interchange with other devices connected to the web.
- On the software side, a web server includes several parts that control how web users access hosted files. At a minimum, this is an HTTP server. An HTTP server is software that understands url (web addresses) and http (the protocol your browser uses to view webpages). An HTTP server can be accessed through the domain names of the websites it stores, and it delivers the content of these hosted websites to the end user’s device.
At the most basic level, whenever a browser needs a file that is hosted on a web server, the browser requests the file via HTTP. When the request reaches the correct (hardware) web server, the (software) HTTP server accepts the request, finds the requested document, and sends it back to the browser, also through HTTP. (If the server doesn’t find the requested document, it returns a 404 response instead.)
Apache Webserver:-
Apache is just one component that is needed in a web application stack to deliver web content. One of the most common web application stacks involves LAMP, or Linux, Apache, MySQL, and PHP.
Let’s started with practical:-
For configured this high level architecture followed by these steps.
Step-1: First login to aws using command line. To login ,we use Access and Secret key provided by IAM AWS service. Use following command…!
aws configure
Step-2:- Create key Pairs and attach to the instance for login.
aws ec2 create-key-pair --key-name <any_name_for_key_here>
Step-3: Create Security Group /Firewall for attaching to the instance. with following command.
aws ec2 create-security-group --group-name my-sg --description "my sg group" --vpc-id <your_VPC_ID_here>
Step-4: Run/Launch the instance and attach the firewall or keypair. with following command
aws ec2 run-instance --image-id <your_image_id_here> --instance-type t2.micro --key-nam <your_keyname_here> --count 1 --security-groups my-sg
Step-5: Login remotely to the instance and configure webserver.
Step-6: Create a EBS volume and attach to the instance.
Step-7:- Create partition and format it.
Step-8: Mount the Drive/Partition with the Mount Point(/var/www/html).
use following command
munt /dev/xvdf1 /var/www/html
Step-9: Create S3 bucket and make the bucket public and upload a image in s3 bucket in make it also public for public access.
aws s3api create-bucket --acl private --bucket <you_bucket_name> --region <your_region> --create-bucket-configuration LocationConstraint=<your_Region_here>
Step-10: Create CloudFront and attach with the s3 bucket to access the all content of bucket using Content Delivery Network (CDN) using there url.
Step-11: Here we deployed the code in (/var/www/html) for the persistent and provide the CloudFront url for access the image from s3 bucket.
use following html code to index.html file, this is your webpage
<html>
<h1> hello world.!! This is my aws CLI. </h1>
<body bgcolor="pink">
<img src="your_image_url_here" width="1300" height="500">
</body>
</html>
Step-12: Start the webserver using this command.
systemctl start httpd
Step-13: Now we can access the web page using the Public IP of Instance via browser.
🙏🙏Thanks for reading the article.🙏🙏