Create CloudFront Architecture with AWS CLI
Ankit Kumar
DevOps| Terraform | Linux |Azure | Azure DevOps | AWS | RH294( Ansible) | Python | Docker | Kubernetes | Grafana | ELK | Prometheus
What is AWS ?
AWS is a Public-Cloud platform providing world-wide service and offer over 170 fully-featured services. It has millions of customers in the world and most recognized companies like NASA, Samsung, Uber, etc, are using AWS services. AWS has the largest community of customers and partners.
What is S3 ?
S3 is known as Simple Storage Service. it is a fully managed service offered by AWS. It is designed to make web-scale computing, especially for the developer. It is Global Service and it offers durability 99.999999999% and availability of 99.99%. It offers infinite storage(that simply means AWS provide storage according to your demand).
What is CDN ?
Content Delivery Network is referred to as a geographically distributed group of the server which helps in faster delivery of Internet content throughout the world. AWS offers CDN service as the name of CloudFront. AWS has connected all over the world through its own network which will help it deliver internet content all over the world. AWS has achieved CDN with the help of Edge-locations. AWS has 155 Edge locations all over the world.
Coming to the task ...!
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 Block Device.
?Static objects used in code such as pictures stored in S3
?Setting up a Content Delivery Network using CloudFront and using the origin domain as an S3 bucket.
?Finally, place the Cloud Front URL on the web app code for security and low latency.
Now let's start the task and perform each step using CLI.
?? First, we have to launch the instance over the AWS and in that instance, we will configure our webserver and perform other processes.
aws ec2 run-instances --image-id { } --instances-type { } --count {} --subnet-id {} --security-group-ids {} --keyname {}
it's time to perform the first step - means configure the webserver.
To configure webserver we use "httpd" software. First, we install the software
yum install httpd -y
Then start the service of httpd.
systemctl start httpd
The next step would is to add the web pages, but before attaching the volume so that webpage becomes persistent.
Step-2: Document Root(/var/www/html) made persistent by mounting on EBS Block Device.
Before proceed to step to we create one EBS volume and then we mount the root directory (/var/www/html) on the ebs volume. This volume we create because we want to store all my website pages in a separate volume so that due to any reason if my OS crashes, in that case, we do not lose the data.
aws ec2 create-volume --avalability-zone {} --size {}
Once you create the volume then attach with the Instances.
aws ec2 atatch-volume --device {} --instance-id {} --volume-id {}
Once it is attached, but cannot use it until you do not make a partition and format it.
fdisk {device name}
mkfs.ext4 {device name}
After format, mount root directory of httpd(/var/www/html) with the ebs volume .
This make /var/www/html made persistent.
Now we can proceed with making HTML pages for the website.
This is the code of the my html page.
Step3: Static objects used in code such as pictures stored in S3.
We generally put the static content in the S3. For this crate one S3 bucket and put the static content.
aws s3api create-bucket --bucket task6bucket --region ap-south-1 --create-bucket-configuration LocationConstraint=ap-south-1
Put the object in the S3 bucket
aws s3 cp {obejct name} s3://{bucketname} --acl public-read-write
acl refers to the Access Control List. acl is one of the resource-based access policy, that you can manage the bucket access.
STEP 4: Finally, place the Cloud Front URL on the web app code for security and low latency.
Now it's time to create Cloud Front in the AWS so that our content would reach each edge location spread all over the world.
aws cloudfront create-distribution --origin-domain-name {}
Now put the Cloudfront URL in the webpage code.
?
The Result of all the processes.
AI/ML Engineer | Building Scalable Solutions with NLP, Computer Vision, and Advanced AI Systems
4 年Nicely done ??