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
- Host: GitHub
- URL: https://github.com/ryands17/s3-thumbnail-generator
- Owner: ryands17
- Created: 2020-09-12T21:03:36.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2024-05-28T08:31:55.000Z (about 2 years ago)
- Last Synced: 2024-05-28T21:19:28.126Z (about 2 years ago)
- Topics: aws, cdk, lambda, s3, sqs
- Language: TypeScript
- Homepage:
- Size: 914 KB
- Stars: 7
- Watchers: 3
- Forks: 6
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# S3 image resizer

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`