Skip to content

Generate thumbnails with S3 via SQS and Lambda created using AWS CDK

Notifications You must be signed in to change notification settings

ryands17/s3-thumbnail-generator

Repository files navigation

S3 image resizer

Build Status

This is an aws-cdk project where you can generate a thumbnail based on S3 event notifications using an SQS Queue with Lambda.

Steps

  1. Change the region in the cdk.context.json to the one where your want to deploy. Default is us-east-2.

  2. Run yarn (recommended) or npm install

  3. Go to the resources folder cd resources.

  4. Run yarn add --arch=x64 --platform=linux sharp or npm install --arch=x64 --platform=linux sharp to build sharp for Lambda.

  5. Go back to the root and run yarn cdk deploy --profile profileName to deploy the stack to your specified region. You can skip providing the profile name if it is default. You can learn about creating profiles using the aws-cli here.

  6. Now you can add image/s in the photos folder in S3 and check after a couple of seconds that images in a folder named thumbnails is generated by Lambda via SQS.

The cdk.json file tells the CDK Toolkit how to execute your app.

Useful commands

  • yarn watch watch for changes and compile
  • yarn test perform the jest unit tests
  • yarn cdk deploy deploy this stack to your default AWS account/region
  • yarn cdk diff compare deployed stack with current state
  • yarn cdk synth emits the synthesized CloudFormation template

Todo

  • Add a DLQ for error processing
  • Replace aws-lambda with aws-lambda-nodejs

About

Generate thumbnails with S3 via SQS and Lambda created using AWS CDK

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •