How to Create an AWS CloudFront Streaming Distribution (and Stream Media Using a JW Player)

How to Create an AWS CloudFront Streaming Distribution (and Stream Media Using a JW Player)

AWS CloudFront is a content distribution service offered by AWS to speed up the distribution of static content, such as media files, html, js, css, etc. CloudFront serves its content through edge locations. As of Dec 2021, AWS had more than 35+ edge locations across the globe. When the user requests for any static content from CloudFront, it will find the nearest edge location to the user and deliver the content from that edge location to reduce the latency.

CloudFront can stream media file using Adobe Real-Time Messaging Protocol (RTMP). The streaming file needs to be on AWS S3 and cannot be served from any other origin.

The present guide demonstrates how to create the CloudFront streaming distribution and stream media using the JW Player.

For streaming the media file, the user needs to provide two types of files: 1) Media file and 2) Media Player file, such as JW Player, Flowplayer or Adobe Flash. The end user will see the media content provided from CloudFront using the media player files provided. The media player file should be uploaded to the AWS S3 bucket and distributed using the download distribution.

1. Create a bucket with AWS S3. Make the bucket publicly accessible with the access policy.

2. Upload the media (video) file to be distributed using CloudFront to the bucket and make it public.

3. Download the Media Player to play the video file uploaded in step#2. The present guide uses the JW Player to stream the video. Download the JW Player from

4. The user can create a separate bucket for the media player. The present guide uses the same bucket for the video file as well as for the media player. Upload the following JW Player files to the AWS Bucket.

a. jwplayer.flash.swf
b. jwplayer.html5.js
c. jwplayer.js

5. Create a download distribution for the bucket created in step #1. The above mentioned download distribution is for the media player files. If the media player files are in some other bucket than specified in step #1, create a distribution for that bucket.

6. Go to the AWS console through Click on CloudFront and go to the CloudFront console. In the CloudFront console click on “Create Distribution”.

7. In the Create Distribution wizard, select the streaming distribution. Click on “Continue”.

8. Provide the values for the streaming distribution settings. Provide the origin ID as the bucket name created in step #1. The other configuration settings are as follows:

a. Restrict S3 Bucket Access: This is used if the user wants the end users to access objects in an Amazon S3 bucket by using only the CloudFront URLs and not directly through the Amazon S3 URLs.
b. Restrict User Access: Allows everyone to view the content using the public URL.
c. Price Class: Allows the user to select the maximum price, which the user is ready to pay for the CloudFront service.
d. CNAMEs: Allows the user to use the URLs for objects instead of the domain name that CloudFront assigns i.e. instead of the CloudFront distribution , the user can specify the custom URL.

9. Provide the logging details. The present guide has selected all the default values for logging. Click on “Create Distribution”.

10. CloudFront will now start to create the distribution. It takes about 5-10 minutes to create a distribution. Initially, when both the distributions (created in steps #5 and #9) are being created, the status will be “In Progress”.

11. Once the distributions have been created, the status will change to “Enable”. Get the domain name of the distribution. The domain name for the download distribution will start with ‘d’ and be in the following format: “”, while for streaming it will start with‘s’ and be in the following format: “”.

12. To test the CloudFront distribution, first create an HTML file which uses the download distribution of the video player and the streaming distribution for the media file uploaded to the origin bucket, as explained in step #2.

13. The above mentioned HTML will not work directly from the local machine.. The user can either host it on some web server and request it or upload to the S3 bucket and access it. For the purpose of testing, upload the file to the same bucket where the media player and media files are uploaded. It is not necessary to keep all the files in the same bucket.

14. When the HTML is requested, it can stream the video. The object uploaded in step #2 will be served from the CloudFront edge location and not directly from the S3 origin. The HTML file can be accessed directly from S3 using the URL provided by the S3 bucket.

15. Since a download distribution has been created for this file in step #5, the user can also request the HTML file through the CloudFront distribution.

Keywords: Amazon Web Services, AWS, Amazon AWS Console, AWS S3, Amazon CloudFront, AWS CloudFront, CloudFront, AWS EC2, AWS ELB, JW Player, AWS Distribution Wizard, CDN, Content Delivery Network

You must be to post a comment.

* As a bonus, you'll receive our weekly newsletter!

Hitchhiker's Guide to The Cloud

Newvem's eBook for Cloud Operations