Testing Lambda Function Operations

Upload and Test Image in S3 Bucket

  1. Access S3 Bucket book-image-stores-by-myself:

S3 Buckets list

  1. Click the Upload button to begin the upload process

Upload to S3

  1. In the Upload interface:
    • Select Add files to add files

Upload interface

  • Select the image file to upload and click Upload

Upload file

  1. Wait for Lambda Function to process:
    • After successful upload

Upload successful

  • Check if the original image has been moved (source bucket will be empty)

Source bucket empty

Access Processed Image

  1. Open destination S3 Bucket book-image-resize-stores-by-myself:

Select destination bucket

  • Find and select the processed image file

Access image

  1. Access the image:
    • Click on Object URL to download the image

Object URL

  1. Handle access error:
    • You will receive an Access Denied message

Access error

Configure Bucket Access Permissions

  1. Set up Bucket policy:
    • Return to Bucket configuration, select the Permissions tab
    • Click Edit in the Bucket policy section

Edit policy

  • Add the following JSON policy:
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::book-image-resize-stores-by-myself/*"
        }
    ]
}
  • Click Save changes to save the policy

Save policy

  1. Confirm the policy has been saved successfully

Policy saved

  1. Verify operation:
  • Try accessing the Object URL again to view the image
  • Compare the resized image with the original to verify the result
  • Lambda Function resize has operated successfully

Resize result