Create High Availability Architecture with AWS CLI
In this article you will get a brief description of how to create an architecture with High Availability.
Task 6
Objectives:-
- Configure a Webserver on EC2 Instance
- Make the Document Root(/var/www/html) persistent by mounting on EBS Block Device.
- Usage of Static objects 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.
AWS CLI
The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.
The AWS CLI v2 offers several new features including improved installers, new configuration options such as AWS Single Sign-On (SSO), and various interactive features.
AWS S3 Service
Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance. This means customers of all sizes and industries can use it to store and protect any amount of data for a range of use cases, such as data lakes, websites, mobile applications, backup and restore, archive, enterprise applications, IoT devices, and big data analytics. Amazon S3 provides easy-to-use management features so you can organize your data and configure finely-tuned access controls to meet your specific business, organizational, and compliance requirements. Amazon S3 is designed for 99.999999999% (11 9's) of durability, and stores data for millions of applications for companies all around the world.
AWS CloudFront Service
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 offers the most advanced security capabilities, including field level encryption and HTTPS support, seamlessly integrated with AWS Shield, AWS Web Application Firewall and Route 53 to protect against multiple types of attacks including network and application layer DDoS attacks. These services co-reside at edge networking locations – globally scaled and connected via the AWS network backbone – providing a more secure, performant, and available experience for your users.
CloudFront works seamlessly with any AWS origin, such as Amazon S3, Amazon EC2, Elastic Load Balancing, or with any custom HTTP origin. You can customize your content delivery through CloudFront using the secure and programmable edge computing feature AWS Lambda@Edge.
Creating and Configuring the Web Server
First, we will create a key pair of the instance to be created in AWS CLI
Then we will create a security group and allow the ports 22 and 80 for the security group
Then we will describe the security groups created for the instance
We will then run an instance using the key-name, security group created above
Then create a tag name for the instance we created using AWS CLI
Creating an EBS volume
Attaching the EBS volume to the instance
Access the instance using the key and IP-address of EC2 instance
Configure the Webserver on the launched instance by installing httpd using following command
Then we will start the webserver using following command and check the status
For Checking If the disk is attached or not we have a command
Formatting and Mounting the disk Created
Then we go to the partition using the below command and create a partition
We then format the disk /dev/xdb1 for mounting
Mounting the /var/www/html on the EBS volume
mount /dev/xvdh1 /var/www/html
Creating the S3 bucket
https://webserbucket.s3.ap-south-1.amazonaws.com/redhat.png
The above is the link to the object created in the bucket. It has a syntax as:-
<https://Bucket_name.s3.region_name.amazonaws.com/object_name>
Creating Cloud Front
We will create a cloudfront by creating a distribution with the following command
aws cloudfront create-distribution --origin-domain-name S3_bucket_name
https://d3j0nrezla7iso.cloudfront.net/redhat.png
For checking the cloud front is working or not we can check it by opening the object by cloud front as <https://domain_name.cloudfront.net/object_name>
When the Cloudfront is ready we can start writing the code
Thanks for reading and hope it will be helpful to you
Feel free to comment
Happy Learning!!