Skip to content

About

imahe size optimizer

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

aws-lambda-s3-image-optimizer

This project is a fully automated serverless architecture example that detects images uploaded to AWS S3 and automatically reduces their size by 50% using the Pillow library.

It demonstrates Infrastructure as Code (IaC) using Terraform and an event-driven workflow powered by AWS Lambda.


Architecture

graph LR
    User(["👤 User"])

    subgraph AWS ["☁️ AWS Cloud"]

        subgraph S3In ["S3 Source Bucket"]
            Raw["proje-raw-images"]
        end

        subgraph Lambda ["AWS Lambda — Python 3.9"]
            Trigger["S3 ObjectCreated\nEvent Trigger"]
            Func["lambda_function.py\nImage Processing"]
            Layer["Pillow Layer\n(Klayers)\nresize → 50%"]
        end

        subgraph S3Out ["S3 Destination Bucket"]
            Opt["proje-optimized-images"]
        end

        CW["CloudWatch\nLogs"]
        IAM["IAM Role\nS3 Read + Write"]

    end

    User -->|"upload image"| Raw
    Raw -->|"ObjectCreated event"| Trigger
    Trigger --> Func
    Func --> Layer
    Layer -->|"save optimized image"| Opt
    Func -->|"execution logs"| CW
    IAM -. "permissions" .-> Func
Loading

Architecture Features

Infrastructure as Code (IaC): All AWS resources (S3, IAM, Lambda) are managed using Terraform.

Event-Driven: The system runs in real time using the S3 ObjectCreated trigger.

Serverless: No server management is required; you only pay when execution happens.

Scalable: Thanks to AWS Lambda, it can process hundreds of images simultaneously.


🚀 Technologies Used

  • Language: Python 3.9
  • Infrastructure: Terraform
  • AWS Services: Lambda, S3, IAM, CloudWatch
  • Libraries: Pillow (PIL), Boto3

📂 Project Structure

  • main.tf — Defines AWS resources such as S3 buckets, IAM roles, and Lambda configuration.
  • lambda_function.py — Contains the image processing logic written in Python.
  • Layers (Klayers) — Lambda layer integration for the Pillow library.

⚙️ Setup and Deployment

Initialize Terraform:

terraform init

Create the infrastructure on AWS:

terraform apply

Upload an image to the proje-raw-images bucket and check the proje-optimized-images bucket!


Ekran görüntüsü 2026-05-13 173357 Ekran görüntüsü 2026-05-13 173343

About

imahe size optimizer

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages