Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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:main
base:main
Choose a base branch
Loading
fromAdityaSriram09:image-resizer-hot-reload
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
AdityaSriram09Oct 5, 2025
eb78023
Rename
AdityaSriram09Oct 5, 2025
ef1e143
Delete src/content/docs/aws/tutorials/S3-Image-Resizer-with-Hot-Reloa…
AdityaSriram09Oct 5, 2025
232e3ac
Create image-resizer-hot-reload.md
AdityaSriram09Oct 5, 2025
ccef634
Update schema-evolution-glue-msk.mdx [#229]
AdityaSriram09Oct 5, 2025
87b5c79
Merge branch 'localstack:main' into main
AdityaSriram09Oct 28, 2025
b714f8a
Remove testing section for MSK and Glue integrations
AdityaSriram09Oct 28, 2025
06081d1
Merge branch 'localstack:main' into image-resizer-hot-reload
AdityaSriram09Oct 31, 2025
e9f505f
Merge branch 'localstack:main' into image-resizer-hot-reload
AdityaSriram09Oct 31, 2025
7aa9cf3
Enhance image resizer tutorial with use cases and clarity
AdityaSriram09Oct 31, 2025
de74a43
Fix issues with frontmatter
remotesynthOct 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 159 additions & 0 deletionssrc/content/docs/aws/tutorials/image-resizer-hot-reload.md
View file
Open in desktop
Original file line numberDiff line numberDiff 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.

[8]ページ先頭

©2009-2025 Movatter.jp