An open API service indexing awesome lists of open source software.

https://github.com/ryands17/s3-thumbnail-generator

Generate thumbnails with S3 via SQS and Lambda created using AWS CDK
https://github.com/ryands17/s3-thumbnail-generator

aws cdk lambda s3 sqs

Last synced: about 1 year ago
JSON representation

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

Awesome Lists containing this project

README

          

# S3 image resizer

![Build Status](https://github.com/ryands17/s3-thumbnail-generator/workflows/CI/badge.svg)

This is an [aws-cdk](https://aws.amazon.com/cdk/) project where you can generate a thumbnail based on [S3 event notifications](https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html) 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](https://docs.aws.amazon.com/cli/latest/reference/configure/#configure).

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`