This is an aws-cdk project where you can generate a thumbnail based on S3 event notifications using an SQS Queue with Lambda.
-
Change the region in the
cdk.context.json
to the one where your want to deploy. Default isus-east-2
. -
Run
yarn
(recommended) ornpm install
-
Go to the resources folder
cd resources
. -
Run
yarn add --arch=x64 --platform=linux sharp
ornpm install --arch=x64 --platform=linux sharp
to buildsharp
for Lambda. -
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 isdefault
. You can learn about creating profiles using the aws-cli here. -
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.
yarn watch
watch for changes and compileyarn test
perform the jest unit testsyarn cdk deploy
deploy this stack to your default AWS account/regionyarn cdk diff
compare deployed stack with current stateyarn cdk synth
emits the synthesized CloudFormation template
- Add a DLQ for error processing
- Replace
aws-lambda
withaws-lambda-nodejs