How to upload and serve data using Amazon CloudFront and Amazon S3 in Node.js

Swathi Prasad
The Startup
Published in
5 min readJul 8, 2019

--

Most of the applications today serve users across the globe and need a way to deliver their content fast. The content can be images, videos, PDF and so on. Content delivery network (CDN) is a network of servers that are geographically distributed with the intent of serving content to users as fast as possible.

Image from Wikipedia

Amazon CloudFront is a content delivery network service which can deliver content fast and secure. In this article, I will describe how to upload files to S3 bucket and serve those files through CloudFront in Node.js. CloudFront will use S3 as an origin in this article.

Prerequisites

Create a bucket in S3 and create a CloudFront distribution in AWS. I will not go into detail about creating S3 bucket and CloudFront distribution in this article. Navigate to IAM and go to ‘Security Credentials’ under user. Create an access key and download the CSV file in case you don’t already have one. We will need this access key later.

Access Keys section under User in IAM

Then, click on ‘My Security Credentials’ under the your account.

--

--

Swathi Prasad
The Startup

Software architect and developer living in Germany. Sharing my opinion and what I learn.