All Projects → skorfmann → cloudfront-image-proxy

skorfmann / cloudfront-image-proxy

Licence: other
Make CloudFront resize images "on the fly" via lambda@edge, cache it and persists it in S3.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to cloudfront-image-proxy

Confetti
🎉 A tool to help creating and deploying static sites with AWS
Stars: ✭ 96 (+200%)
Mutual labels:  s3, cloudfront
CloudHunter
Find unreferenced AWS S3 buckets which have CloudFront CNAME records pointing to them
Stars: ✭ 31 (-3.12%)
Mutual labels:  s3, cloudfront
Scar
Deploy static websites in seconds - with HTTPS, a global CDN, and custom domains.
Stars: ✭ 1,715 (+5259.38%)
Mutual labels:  s3, cloudfront
Workshop Donkeytracker
Workshop to build a serverless tracking application for your mobile device with an AWS backend
Stars: ✭ 27 (-15.62%)
Mutual labels:  s3, cloudfront
ipx
High performance, secure and easy to use image proxy based on Sharp and libvips.
Stars: ✭ 683 (+2034.38%)
Mutual labels:  libvips, sharp
Cyberduck
Cyberduck is a libre FTP, SFTP, WebDAV, Amazon S3, Backblaze B2, Microsoft Azure & OneDrive and OpenStack Swift file transfer client for Mac and Windows.
Stars: ✭ 1,080 (+3275%)
Mutual labels:  s3, cloudfront
Lad
👦 Lad is the best Node.js framework. Made by a former Express TC and Koa team member.
Stars: ✭ 2,112 (+6500%)
Mutual labels:  s3, cloudfront
simply-static-deploy
WordPress plugin to deploy static sites easily to an AWS S3 bucket.
Stars: ✭ 48 (+50%)
Mutual labels:  s3, cloudfront
s3redirect
Turn S3 into a URL redirect website using lambda and NO database!
Stars: ✭ 31 (-3.12%)
Mutual labels:  s3, cloudfront
aws-pdf-textract-pipeline
🔍 Data pipeline for crawling PDFs from the Web and transforming their contents into structured data using AWS textract. Built with AWS CDK + TypeScript
Stars: ✭ 141 (+340.63%)
Mutual labels:  s3, cdk
S3 Deploy Website
Deploy website to S3/CloudFront from Python
Stars: ✭ 26 (-18.75%)
Mutual labels:  s3, cloudfront
live-streaming-on-aws-with-mediastore
Live streaming on AWS with Amazon S3 automatically configures AWS Elemental MediaLive, Amazon S3 and Amazon CloudFront to ingest, encode, package and deliver a single source live stream through the AWS Cloud. The Solution provides 3 Encoding profiles to support 1080p through 288p HTTP live streaming (HLS) outputs.
Stars: ✭ 84 (+162.5%)
Mutual labels:  s3, cloudfront
Aws
A collection of bash shell scripts for automating various tasks with Amazon Web Services using the AWS CLI and jq.
Stars: ✭ 493 (+1440.63%)
Mutual labels:  s3, cloudfront
React Deploy S3
Deploy create react app's in AWS S3
Stars: ✭ 66 (+106.25%)
Mutual labels:  s3, cloudfront
Mort
Storage and image processing server written in Go
Stars: ✭ 420 (+1212.5%)
Mutual labels:  s3, libvips
Terraform Aws Cloudfront S3 Cdn
Terraform module to easily provision CloudFront CDN backed by an S3 origin
Stars: ✭ 162 (+406.25%)
Mutual labels:  s3, cloudfront
serverless-aws-static-websites
Deploy your static websites without all the hassle on AWS with CloudFront, S3, ACM and Route53 via Serverless
Stars: ✭ 121 (+278.13%)
Mutual labels:  s3, cloudfront
Dive-Into-AWS
Links to the Repos and Sections in our Dive into AWS Course.
Stars: ✭ 27 (-15.62%)
Mutual labels:  s3, cloudfront
Gatsby Plugin S3
Deploy your gatsby site to a S3 bucket.
Stars: ✭ 186 (+481.25%)
Mutual labels:  s3, cloudfront
react-deploy-s3
Deploy create react app's in AWS S3
Stars: ✭ 67 (+109.38%)
Mutual labels:  s3, cloudfront

CloudFront Image Proxy

Make CloudFront resize images "on the fly" via lambda@edge, cache it and persists it in S3. Utilises Sharp for image transformations.

Schema

Illustration & inspiration from this blog post

Package & Deploy

This makes use of the AWS CDK

yarn install
cdk deploy

Usage

Once deployed, upload an image (example.jpg) to the created S3 bucket in an images folder (images/example.jpg). Now you can request this image via the Cloudfront distribution domain https://<distribution>.cloudfront.net/images/example.jpg, or generate other versions of it like that https://<distribution>.cloudfront.net/images/example.jpg?d=200x200.

At the moment, there's little sanity checking or error handling, and the only implemented image transformation option is the resizing. However, exposing more options of sharp is just a bunch of typing ;) Check the end of the Readme for more ideas.

Cost Estimation

It's not really straightforward to estimate the pricing. The AWS Calculator is not helpful for the resources used here. A back of the napkin estimate for an example image taken from unsplash (4899 × 3266, 1.8 MB):

Cost Estimation Original

While data transfer from AWS origins to Cloudfront is free, data transfer to Lambda@edge is not (unless in the same region). Therefore, the data transfer cost seems to be a significant part of the equation. I think it would make sense, to generate a few (small / medium / large) versions after the image upload, so that the data transfer is not that costly. See this example, where the same image got transformed to 1920x180 and just 250 KB:

Cost Estimation Medium

Interestingly enough, the processing time of the image conversion lambda isn't much different for both versions. The next improvement which could make sense, is either moving the Bucket in the region where most of the traffic is happening, or to create an API Gateway / Lambda combo to perform the actual image conversion wihin one region.

SaaS Comparison

Comparing this with a service like imgix:

  • 1000 original images access per month (all conversions included): 3 USD
  • 1 GB CDN data transfer: 0.08 USD

Assuming we generate 10 versions for each original image, this Cloudfront proxy clocks in at around 0.85 USD for 10k generated images (inkl CDN traffic). Since CDN traffic cost for subsequently cached image requests is more or less the same for imigix and Cloudfront we can ignore this factor.

The Cloudfront version runs at roughly 30% of the cost of imgix. However, since imgix is a SaaS offering, it's an unfair comparison and you should take engineering time and opertional burdens into account. Having said that, it's still interesting to see those numbers side by side.

If you're interested in more details about the cost estimation, get in touch please.

Lambda@Edge Gotchas

Further Ideas

  • Split lambda@edge functions into separate stack, so not all the resources have to be deployed to us-east-1
  • Unit / Integration tests
  • Cloudinary compatible URL param structure
  • Make the resizing more resilient (allow something like x300 to scale one dimension dynamically)
  • Change File Structure in S3 to make it easy to delete files - something like images//300x200/
  • Pre Generate low res images for large images to improve conversion speed (e.g. 6000x4000 could pre generate 3000x2000(high) / 1000x667(medium) / 500x226(small))
  • Option for snap dimensions (401x303 => 400x300)
  • Expose more Sharp features
  • Client libraries
  • On-Demand external image source e.g. fetch original image from mydomain.com and persist it in S3
  • Add Kinsesis Firehose to aggregate all CloudWatch logs from functions across all edge locations
  • Multiple Tenants
  • Provide packages as jsii packges for Python / C# / Java
  • Analytics / Dashbords / Reporting

Similar projects

Standalone Server

AWS S3 Trigger

AWS API Gateway

SaaS

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].