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 CloudFront and using the origin domain as S3 bucket.
✔ Finally place the Cloud Front URL on the WebApp code for security and low latency.
STEP 1: Create AWS EC2 Instance:
you can create an AWS EC2 instance from GUI or by using the below command:
I am already having an instance named task6 (which is in the stopped state)
For starting the Instance we need to use the following command:
Now, we can see the task6 instance is running:
STEP 2: Webserver configuration on EC2 Instance
For configuration of web server, we need to install httpd software using command: # yum install httpd and start the httpd service using the command: #systemctl start httpd
STEP 3: Create an EBS volume of 1 GB
AWS Command to create EBS volume:
command output:
Now, we can also see in the GUI, volume of 1GB is created:
STEP 4: Attach this EBS volume of 1 GB with EC2 Instance
AWS Command to attach volume:
Command output:
Now, we can see the 1GB of volume is attached:
STEP 5: Create a partition, format and mount it to /var/www/html
Now, we have successfully made Document Root(/var/www/html)
persistent by mounting on EBS Block Device.
STEP 6: Create AWS S3 Bucket
AWS Command to create S3 bucket:
# aws s3api create-bucket — bucket webimages9 — region ap-south-1 — create-bucket-configuration
Now, we can see the S3 bucket is created:
STEP 7: Upload Images to the ‘webimages9' bucket
STEP 8: Create a CloudFront Distribution
Command to create CloudFront Distribution:
# aws cloudfront create-distribution — origin-domain-name webimages9.s3.amazonaws.com
STEP 9: Create HTML file in instance and provide image URL of CloudFront to this HTML file
STEP 10: Check Website Hosted Successfully or Not
if I type http://13.232.42.232/index.html I am getting my index.html page output 😃
But on this website, all the images are coming from AWS CloudFront.
Thank you for reading!! 😇
index.html (which I uploaded at /var/www/html location):