Creating a Lambda Function for Image Processing

Creating a Lambda Function

  1. Navigate to AWS Lambda Console and select Create function.

Lambda Console Interface

  1. On the Create function page:
    • Select Author from scratch
    • Name your function (e.g., resize-image)
    • Choose Node.js 20.x as the Runtime
    • Keep other settings at their defaults and click Create function

Creating Lambda Function

Configuring Source Code

  1. Download the sample source code:

  2. function.zip (25968 ko)
  3. On the resize-image page:

    • Select Upload from
    • Choose .zip file

Uploading Source Code

  1. In the Upload a .zip file dialog:
    • Click Upload and select your downloaded source code file
    • Click Save to confirm

Confirming Upload

Setting Up the Environment

  1. On the resize-image function page:
    • Switch to the Configuration tab
    • Select Environment variables from the left menu
    • Click Edit

Configuring Environment

  1. On the Edit environment variables page:
    • Add the following environment variables:
      • WIDTH: New image width (e.g., 200px)
      • HEIGHT: New image height (e.g., 280px)
      • DES_BUCKET: Destination S3 bucket name (e.g., book-image-resize-stores-by-myself)
    • Click Save to apply the configuration

Setting Environment Variables

Next Steps

After completing the Lambda function configuration and environment variables setup, the next step is to create S3 buckets for storing both original and processed images.