CLOUDFRONT WITH S3 BUCKET ORIGIN
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”.
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.
Click on “Create bucket”.
Open the bucket and upload a file to the bucket.
Click on “Upload”.
Click on “Add files” and upload the files.
Your file should now appear in the bucket.
Under “Services” search for “Cloudfront” and click on “CloudFront”
Open CloudFront and create a distribution.
Click on “Get Started” under “Create a web distribution”.
Insert the bucket name under the Origin domain name
Restrict the Bucket Access
Create a new Identity
Select “Yes, update bucket policy”
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
It will take about 10 minutes for your distribution to go from “In process” to “Deployed”
Copy the CloudFront Domain name.
Here you go, you are now a pro when it comes to deploying an S3 bucket with CloudFront.