- Notifications
You must be signed in to change notification settings - Fork23
Image resizer hot reload [#237]#303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
AdityaSriram09 wants to merge11 commits intolocalstack:mainChoose a base branch fromAdityaSriram09:image-resizer-hot-reload
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes fromall commits
Commits
Show all changes
11 commits Select commitHold shift + click to select a range
829ecda Create Serverless Image Resizer with Hot Reload.md #237
AdityaSriram09eb78023 Rename
AdityaSriram09ef1e143 Delete src/content/docs/aws/tutorials/S3-Image-Resizer-with-Hot-Reloa…
AdityaSriram09232e3ac Create image-resizer-hot-reload.md
AdityaSriram09ccef634 Update schema-evolution-glue-msk.mdx [#229]
AdityaSriram0987b5c79 Merge branch 'localstack:main' into main
AdityaSriram09b714f8a Remove testing section for MSK and Glue integrations
AdityaSriram0906081d1 Merge branch 'localstack:main' into image-resizer-hot-reload
AdityaSriram09e9f505f Merge branch 'localstack:main' into image-resizer-hot-reload
AdityaSriram097aa9cf3 Enhance image resizer tutorial with use cases and clarity
AdityaSriram09de74a43 Fix issues with frontmatter
remotesynthFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| --- | ||
| title: S3 Image Resizer with Lambda (Hot Reload) | ||
| description: Learn how to build and test a serverless image resizing pipeline locally using LocalStack Pro with Lambda hot reload support. | ||
| services: | ||
| - sqs | ||
| - lmb | ||
| - s3 | ||
| platform: | ||
| - nodejs | ||
| pro: true | ||
| deployment: | ||
| - docker-compose | ||
| leadimage: "image-resizer-hot-reload.png" | ||
| --- | ||
| # S3 Image Resizer with Lambda (Hot Reload) | ||
| ## Introduction | ||
| In this tutorial, you’ll learn how to build and run a **serverless image resizing pipeline** locally using **LocalStack Pro**. | ||
| The workflow is simple: | ||
| 1. Upload an image to an **S3 source bucket**. | ||
| 2. An **AWS Lambda** function automatically resizes the image. | ||
| 3. The resized image is written back to an **S3 target bucket**. | ||
| 4. Using **hot reload**, you can modify Lambda code locally and instantly test changes without redeployment. | ||
| This pattern is ideal for developing and testing serverless media-processing workflows like thumbnails, avatars, and dynamic image scaling. | ||
| ## Prerequisites | ||
| Make sure you have the following installed and configured: | ||
| - **LocalStack Pro** (hot reload support requires Pro) | ||
| - **Docker** (to run LocalStack services) | ||
| - **Node.js** *or* **Python** (depending on the Lambda runtime used) | ||
| - **AWS CLI** or **awslocal** | ||
| - **Make** (optional, for running build scripts) | ||
| - Basic understanding of AWS Lambda and S3 event triggers | ||
| ## Why / Use Case | ||
| Image resizing is a fundamental part of many web applications — whether you’re: | ||
| - A **CMS platform** generating thumbnails for uploaded images | ||
| - An **e-commerce store** optimizing product visuals | ||
| - A **developer** testing media pipelines before production | ||
| Running this workflow locally with LocalStack lets you: | ||
| - Develop and debug Lambdas faster (no redeploys) | ||
| - Avoid AWS costs during experimentation | ||
| - Simulate a realistic event-driven workflow | ||
| ## Architecture Diagram | ||
| ```text | ||
| ┌────────────────────┐ | ||
| │ Source S3 │ | ||
| │ (e.g. input-bucket)│ | ||
| └───────┬────────────┘ | ||
| │ | ||
| (S3 Event Trigger) | ||
| │ | ||
| ▼ | ||
| ┌────────────────────┐ | ||
| │ Lambda │ | ||
| │ (Image Resizer) │ | ||
| └───────┬────────────┘ | ||
| │ | ||
| ▼ | ||
| ┌─────────────────────┐ | ||
| │ Target S3 Bucket │ | ||
| │ (e.g. output-bucket)│ | ||
| └─────────────────────┘ | ||
| ``` | ||
| ## Steps | ||
| ### 1. Clone the Repository | ||
| ``` | ||
| git clone https://github.com/localstack-samples/sample-lambda-s3-image-resizer-hot-reload.git | ||
| cd sample-lambda-s3-image-resizer-hot-reload | ||
| ``` | ||
| ### 2. Install Dependencies | ||
| If using Python: | ||
| ``` | ||
| python -m venv .venv | ||
| source .venv/bin/activate | ||
| pip install -r requirements-dev.txt | ||
| ``` | ||
| If using Node.js Lambdas: | ||
| ``` | ||
| npm install | ||
| ``` | ||
| ### 3. Start LocalStack | ||
| Make sure your LocalStack Pro token is set: | ||
| ``` | ||
| localstack auth set-token <your-auth-token> | ||
| localstack start | ||
| ``` | ||
| ### 4. Build and Deploy the Lambda | ||
| ``` | ||
| Run the provided scripts to build and deploy: | ||
| deployment/build-lambdas.sh | ||
| deployment/awslocal/deploy.sh | ||
| ``` | ||
| This sets up S3 buckets, event triggers, and deploys the Lambda function locally. | ||
| ### 5. Upload a Sample Image | ||
| Once deployment completes, upload a sample image to the input bucket: | ||
| ``` | ||
| awslocal s3 cp ./samples/test-image.jpg s3://input-bucket/ | ||
| ``` | ||
| The Lambda will trigger automatically and write the resized image to s3://output-bucket/. | ||
| ## Testing the Application | ||
| ### Step 1: Verify the Resized Image | ||
| * List files in the output bucket: | ||
| ``` | ||
| awslocal s3 ls s3://output-bucket/ | ||
| ``` | ||
| * Download and inspect the resized image: | ||
| ``` | ||
| awslocal s3 cp s3://output-bucket/test-image.jpg ./output/ | ||
| ``` | ||
| * Confirm the dimensions (e.g., via any image viewer or identify command from ImageMagick): | ||
| ``` | ||
| identify ./output/test-image.jpg | ||
| ``` | ||
| ### Step 2: Test Hot Reload | ||
| * Modify your Lambda code locally (for example, change the resize dimensions or add a watermark). | ||
| * Hot reload automatically detects changes—no redeploy needed. | ||
| * Upload another image (or the same one under a new name): | ||
| ``` | ||
| awslocal s3 cp ./samples/test-image2.jpg s3://input-bucket/ | ||
| ``` | ||
| Verify that the new logic is applied (e.g., updated size or watermark visible). | ||
| ## Conclusion | ||
| You’ve built and tested a complete serverless image pipeline on LocalStack, featuring: | ||
| S3 → Lambda → S3 event-driven workflow | ||
| Hot reload for rapid local iteration | ||
| End-to-end testing of serverless image processing | ||
| This pattern can easily extend to real-world use cases—such as photo galleries, CMS platforms, or social apps—where dynamic image transformation is essential. |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.