This article gives you the basic description about AWS S3 bucket connect with AWS CloudFront service.
AWS S3 CLOUD FRONT
Amazon CloudFront is a Content Delivery Network (CDN) 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.
To get more info About AWS CloudFront click here.
Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance. It stores objects in buckets and have various storage classes.
To get more info About AWS S3 click here.
Follow below steps to complete the task:
Login to AWS if you are already registered. if not, get an AWS Account
Create S3 Bucket from S3 service.
Make bucket and objects public
Go to CloudFront service and connect your s3 bucket
Login with AWS account with this link click-here.
1. Search s3 service and create bucket.
2. Type your bucket name.
3. Uncheck Block public access. In my case I have checked the checkbox it but you need to uncheck it.
And click on save. From this action your bucket will be created and will be available on dashboard. Your next would be to upload an object in that bucket and make that object "Public" for an access.
I have already uploaded an image in my bucket which is awscloud.jpg. You can simply upload an object by "upload" button, also you can create a new folder inside your bucket by "create folder" option.
So to make your bucket public, you need to select your object and go to Actions, click on Make public option from drop down, you will be redirected to next page and click on "Make Public".
To access an image, click on your image name from the list and click on the link "Object Url" which will be given on description page.
You will be redirected to browser with s3 link. If you see access denied page, you need to check if your bucket/object is public or not.
Now search CloudFront from AWS search bar, click on CloudFront service.
Click on Create Distribution
Click on Get Started
In origin Domain Name, select your bucket name which you have created.
And do not change any settings, click on create distribution in last.
You will be redirected to dashboard with the status "In Prog". It will took time to change status "Deployed". Once it deployed, you will get a domain name of CDN. This domain name will help you to get your object through CloudFront.
To access object from S3, get CDN Domain name and add "/" object name from your s3 bucket if you are accessing image manually. In my case, http://d3999rx8f5tl1f.cloudfront.net/awscloud.jpg, and you will get the result.
CloudFront will get your result and cached in the edge location. If there is any new request found for the same image, it will loads it from cache and send the result to end user. This will make the media response time faster in your website or in any other application.