Cloud Front Distribution on AWS

Vibhanshusharma
3 min readMar 21, 2021

Amazon 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 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.

Steps required for using CloudFront-

  1. Create an instance with a web server configured attached with 1gb EBS (Elastic Block Storage) make our data persistent.

2.Create S3 Bucket and adding static files to it.

3. Create Origin Access Identity.

4. Create Cloudfront Distribution.

5. Updating Bucket policy.

Step1- Create an ec2 instance, you can either use GUI or CLI to perform this step.

After creating in instances section you can see your newly created instance as in above photos.

CLI command is

aws ec2 run-instance –image-id ami-<image-id>— instance-type t2.micro — subnet-id subnet-<subnet-id> — count 1 -security-group-ids <sg-id>— key-name <value>

Step2- Login as super user and install httpd

CLI commands are-

sudo su

yum install httpd

Step3- Create an EBS volume of 1gb.

Step4- Attach your EBS to instance

To check the attached volume command is

fdisk -l

Step5- Format and mount the created partition.

CLI commands are

mkfs.ext4 /dev/xvdf

mount /dev/xvdb /var/www/html

Step6-

· Change directory to “cd /var/www/html/”

· Create a file “vim index.html” and write some content in the file.

Step7— Start your HTTPD service

Step8- Create S3 bucket

CLI is

aws s3 mb s3://awss3mybucket— region ap-south-1

Step9- Copy your files in Bucket

Step10- CloudFront distribution

aws cloudfront create-distribution — origin-domain-name awss3mybucket.s3.ap-south-1.amazonaws.com — default-root-object index.html

Now provide the domain name of distribution in the index.html file.

Now can access your website

ThankYou

--

--