This repository contains an AWS Cloud Development Kit (CDK) project written in TypeScript, designed to demonstrate a simple image resizing solution on AWS. The solution involves deploying a stack that contains two Amazon S3 buckets and an AWS Lambda function.
- S3 Bucket 1: Holds original-sized images.
- S3 Bucket 2: Stores the resized images.
- Lambda Function: Handles the resizing process using the Sharp npm library.
Before deploying this application, ensure you have the following:
- AWS CLI installed and configured.
- Node.js and npm installed.
- AWS CDK installed (
npm install -g aws-cdk). - An existing Sharp layer in your AWS account. If you don't have it, follow the instructions in the "Sharp Layer Deployment" section.
If you do not have a Sharp layer deployed in your AWS account, you can deploy it using the following steps:
-
Visit the AWS Sharp Layer Repository.
-
In the README, click on the "releases" link and download the latest
sharpzip file to your computer. -
Open your terminal and execute the following command to deploy the Sharp package to AWS Lambda:
aws lambda publish-layer-version \ --layer-name sharp \ --description "Sharp layer" \ --license-info "Apache License 2.0" \ --zip-file fileb://dist/sharp-layer.zip \ --compatible-runtimes nodejs14.x nodejs16.x nodejs18.x \ --compatible-architectures x86_64 arm64
To deploy the AWS CDK Simple Image Resizer application:
- Clone this repository to your local machine.
- Navigate to the repository directory.
- Run
npm installto install the necessary dependencies. - Execute
npx aws-cdk deployto deploy the application stack to your AWS account.
After deployment, upload an image to the first S3 bucket. The Lambda function will automatically resize the image and place the resized version in the second S3 bucket.
When testing in the AWS Lambda console, you should receive a presigned URL:

Contributions are welcome. Please open an issue or submit a pull request with your changes.
