CLOUDFRONT WITH S3 BUCKET ORIGIN

Hello World,

Today I will show you how to protect your S3 bucket from direct public access and how to reduce latency using CloudFront.

Step 1. Create an Amazon S3 bucket

From the AWS Management Console click on “Services” search for “S3” and click on “S3”

While in “S3” Click on “Create bucket”.

Image for post
Image for post

Enter the name of your bucket and select the region where you will like to operate. Please note that the name must be unique and must meet the naming guidelines.

Image for post
Image for post

Click on “Create bucket”.

Image for post
Image for post

Open the bucket and upload a file to the bucket.

Image for post
Image for post

Click on “Upload”.

Image for post
Image for post

Click on “Add files” and upload the files.

Image for post
Image for post

Your file should now appear in the bucket.

Image for post
Image for post

Under “Services” search for “Cloudfront” and click on “CloudFront”

Open CloudFront and create a distribution.

Click on “Get Started” under “Create a web distribution”.

Image for post
Image for post

Insert the bucket name under the Origin domain name

Restrict the Bucket Access

Create a new Identity

Select “Yes, update bucket policy”

Image for post
Image for post

Under “Distribution Settings” in the Default Root object field enter the name of the file that you uploaded to the bucket. In my case is s3bucket.html

Image for post
Image for post

It will take about 10 minutes for your distribution to go from “In process” to “Deployed”

Copy the CloudFront Domain name.

Image for post
Image for post
Image for post
Image for post

Here you go, you are now a pro when it comes to deploying an S3 bucket with CloudFront.

Written by

AWS Certified Cloud Practitioner | UMBC Alum

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store