AWS Builder Center

Title: Building a Serverless Image Processing Workflow with AWS Lambda and Amazon S3

Learn how to automatically process uploaded images using Amazon S3 events and AWS Lambda with a simple hands-on example.

Information Technology Student | AI/ML & Generative AI | Python | AWS
Cloud applications often need to process files automatically after users upload them. Instead of running a server continuously, developers can use AWS serverless services to build event-driven workflows.
Amazon S3 and AWS Lambda make this possible by triggering code whenever a new file is uploaded.

Five important concepts

  1. Amazon S3: Stores uploaded files securely and reliably.
  1. AWS Lambda: Executes code without managing servers.
  1. Event Notifications: Trigger Lambda functions when new objects arrive.
  1. IAM Roles: Provide permissions for Lambda to access required AWS resources.
  1. CloudWatch: Helps monitor function execution and troubleshoot errors.

Hands-on AWS Example: Automatic Image Upload Notification

Objective: Create a workflow that automatically runs a Lambda function whenever an image is uploaded to an S3 bucket.
Step 1: Create an S3 bucket
  • Open the AWS Management Console.
  • Navigate to Amazon S3.
  • Create a uniquely named bucket.
  • Keep Block Public Access enabled.
Step 2: Create a Lambda function
  • Open AWS Lambda.
  • Create a function using Python.
  • Select a suitable execution role with permission to read objects from your bucket.
Step 3: Add Python code
def lambda_handler(event, context):
for record in event['Records']:
bucket = record['s3']['bucket']['name']
file_name = record['s3']['object']['key']

print(f"New image uploaded: {file_name}")
print(f"Bucket: {bucket}")

return {"status": "success"}
Step 4: Configure the S3 trigger
  • Open your Lambda function.
  • Add an S3 trigger.
  • Select your bucket.
  • Set the event type to  PUT .
  • Add an image suffix filter such as  .jpg .
Step 5: Test the workflow
  • Upload a JPG image to your S3 bucket.
  • Open the Lambda Monitor section.
  • View CloudWatch logs to confirm that the function detected the uploaded file.
Expected Output:
New image uploaded: sample.jpg
Bucket: your-s3-bucket

What You Learn

By completing this exercise, you understand how event-driven architecture works, how AWS services communicate, and how to automate application workflows without managing servers.
Important: Use a test bucket, configure only the required IAM permissions, and delete unused resources after testing to avoid unnecessary AWS charges.
Small hands-on experiments like this are a great way to turn cloud computing concepts into practical development skills.
What AWS service would you like to explore in your next hands-on project?
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article