
Serverless Image Organizer with Rekognition & Terraform.
Automatically sorts images by recognizing faces and organizing media of specific people from large folders.
Published Apr 6, 2025
Have you ever found yourself drowning in thousands of photos, desperately looking for pictures of specific people? In this article, I’ll walk you through building Quick Face Sort, an automated solution that uses AWS’s facial recognition capabilities to organize your images.
Most of us accumulate thousands of images through messaging apps like WhatsApp. While a lot of these are memes or screenshots we don’t need to keep, some contain precious moments with family and friends. Manually sorting through this digital pile is time-consuming and tedious.

Quick Face Sort is a serverless application that: 1. Takes reference photos of people you want to find 2. Scans through your image collection 3. Automatically groups photos containing those people
The entire process is event-driven and serverless, meaning it scales automatically and you only pay for what you use.
The solution uses these AWS services:
- S3: Two buckets, one for reference faces and another for images to be sorted
- Lambda: Serverless function that processes images using facial recognition
- Rekognition: AWS’s AI service for image analysis
- CloudWatch: For monitoring and logging
- You upload reference photos to the reference S3 bucket
- You upload your unsorted photos to the database S3 bucket
- S3 event notifications trigger the Lambda function
- The Lambda function uses AWS Rekognition to compare faces
- Images with matching faces (>95% similarity) are organized into folders
- Results are logged to CloudWatch for monitoring
Let’s dive into the code. We’ll use Terraform to define our infrastructure as code:
The Lambda function uses Python and the Boto3 SDK to:
- List images in both buckets
- Compare faces using Rekognition
- Organize matches into folders
Deploying the solution is straightforward:
This solution uses several AWS services that incur costs:
- S3 storage for your images
- Lambda function invocations
- Rekognition API calls
- CloudWatch Logs
The good news is that AWS’s pricing model means you only pay for what you use. For personal photo libraries, costs should be minimal.
The application uses best practices for security:
- Private S3 buckets with no public access
- Least-privilege IAM permissions
- No long-term storage of facial recognition data
Quick Face Sort demonstrates the power of combining serverless computing and AI services to solve real-world problems. With minimal code and maintenance, you can build a solution that automatically organizes thousands of photos, saving hours of manual work.
The complete code is available on GitHub - feel free to use it, contribute, or adapt it for your needs.
Have you built something similar? How do you organize your photo collections? I’d love to hear your thoughts and questions in the comments! 😊🧡