Image resizing on the fly using AWS.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
imabritishcow 58274e9df6 First commit 12 months ago
.gitignore First commit 12 months ago
LICENSE.md First commit 12 months ago
README.md First commit 12 months ago
index.ts First commit 12 months ago
package.json First commit 12 months ago
tsconfig.json First commit 12 months ago
yarn.lock First commit 12 months ago

README.md

img-resize

Image resizing on the fly using AWS.

Setup

  1. Create an S3 bucket with all your images, make sure it can be accessed publically by the function.

  2. Create a function with this code and set an environment variable, BASE_URL. The BASE_URL is where your images are (ex. https://my-s3-bucket.s3.amazonaws.com/)

  3. Create a REST API in API Gateway. Make a method with {proxy+} and add a Lambda proxy integration.

  4. (optional) Setup custom domain with API Gateway (also required to use CloudFront). Choose a regional endpoint and select an ACM certificate for your domain, if you are using Cloudflare you will have to get an origin certificate and upload it to ACM.

  5. (optional) Create a new CloudFront distribution and set the origin to the endpoint API Gateway gave you when setting up the custom domain. Add your domain to the alernate domains. You also need to add the headers Accept and the query strings w and h to your cache key whitelist. And whitelist query string w and h in your origin request policy.