Oct 14, 2025 2 min read

Building a Serverless Photo Uploader with AWS Lambda, API Gateway, and S3 (Free-Tier Project)

Building a Serverless Photo Uploader with AWS Lambda, API Gateway, and S3 (Free-Tier Project)

Building a Serverless Photo Uploader with AWS Lambda, API Gateway, and S3 (Free-Tier Project)

In today's cloud-first world, serverless applications are transforming how developers build and deploy apps. Instead of managing servers, we focus on writing code and letting AWS handle scaling, availability, and infrastructure.

In this post, I'll walk you through how I built a Serverless Photo Uploader using AWS Lambda, API Gateway, and S3, fully deployed through Terraform.\ This project helped me deeply understand how frontend apps talk to AWS backends and how pre-signed URLs make uploads secure and cost-effective.

Architecture Overview

Here's what happens when a user uploads a photo:

  1. The browser requests a pre-signed URL from API Gateway (GET /presign).

  2. API Gateway triggers a Lambda function.

  3. Lambda generates a temporary pre-signed S3 URL (valid for 5 minutes).

  4. The browser uses that URL to upload directly to S3 using PUT.

AWS Serverless Photo Uploader
Diagram

This eliminates the need for an EC2 server or backend API --- keeping costs close to zero.

Why Use API Gateway?

API Gateway acts as the secure middleman between the browser and Lambda.\ Without it, your Lambda would not have a public endpoint.

It provides: - HTTPS access to Lambda\

With this setup, your frontend can safely communicate with AWS services through one HTTPS URL.

What Is a Pre-Signed URL?

A pre-signed URL is a temporary, secure link generated by AWS.\ It allows clients (like browsers) to upload or download objects from S3 without needing AWS credentials.

url = s3.generate_presigned_url(
    ClientMethod='put_object',
    Params={'Bucket': 'photo-uploader', 'Key': 'uploads/x.png'},
    ExpiresIn=300
)

The result is a long, signed URL that only works for that specific file and time window --- keeping your S3 bucket private and safe.

Tools Used

Tool Purpose

AWS S3 Store uploaded images AWS Lambda (Python) Generate pre-signed URLs Amazon API Gateway Expose Lambda as a public API Terraform Automate all resource provisioning HTML + JS (Frontend) Upload files from browser directly to S3

How It Works

  1. User opens the S3-hosted static website.\
  2. JS code sends a request to the API Gateway /presign endpoint.\
  3. Lambda checks if the file exists, and if not, creates a pre-signed URL.\

  4. Browser uploads directly to S3 using that URL.\

  5. Uploaded image appears instantly in your S3 bucket.

Lessons Learned

GitHub Repo

👉 Serverless Photo Uploader on GitHub

Check out the repository for the full Terraform configuration, Lambda code, and static site example.

Conclusion

Building this project helped me move from theory to real-world AWS experience.\ It's a great AWS Developer Associate--level hands-on project and runs easily within the free tier.

Next, I plan to integrate DynamoDB to store metadata and Cognito for authentication. Stay tuned for part 2!

Tags: #AWS #Serverless #DevOps #CloudComputing #Terraform #Lambda

APIgateway #S3 #DeveloperAssociate

Liked this? Get more in your inbox.

One short email when I publish. AWS, AI, and founder notes — no spam, unsubscribe in one click.

By JOY 7 months, 3 weeks ago

// Read next

How to Host Your Static Website on AWS S3 and CloudFront (Step-by-Step Guide)

# 🌍 Day 1 — Host a Static Website on AWS (S3 + CloudFront) When I started my …

AWS EventBridge Explained: The Ultimate Q&A Guide for Developers (with Real-Life Examples)

# 🧩 AWS EventBridge Explained: The Ultimate Q&A Guide for Developers (with Real-Life Examples) ## 🧠 1. What …

AWS API Gateway: A Practical, Step-by-Step Guide

## 🔗 What Is API Gateway? AWS API Gateway is the **entry point** for your backend APIs. It …