🚀AWS Lambda S3 File Upload Logger using Python

Published: (February 1, 2026 at 11:50 AM EST)
1 min read
Source: Dev.to

Source: Dev.to

Project Overview

In this project, I implemented an AWS Lambda function using Python that automatically logs file upload details whenever a file is uploaded to an Amazon S3 bucket. This demonstrates a real‑time, event‑driven architecture using AWS services.

Flow

  • File uploaded to S3 bucket
  • S3 triggers AWS Lambda
  • Lambda extracts file details
  • Logs stored in CloudWatch

Services Used

  • Amazon S3
  • AWS Lambda (Python)
  • Amazon CloudWatch

Lambda Function (Python)

def lambda_handler(event, context):
    record = event['Records'][0]
    bucket_name = record['s3']['bucket']['name']
    file_name = record['s3']['object']['key']
    file_size = record['s3']['object']['size']

    print(f"Bucket Name: {bucket_name}")
    print(f"File Name: {file_name}")
    print(f"File Size: {file_size} bytes")

CloudWatch Logs Output

After uploading a file to the S3 bucket, the Lambda function logged:

  • Bucket Name
  • File Name
  • File Size

This confirms the function executed successfully.

GitHub Repository

Back to Blog

Related posts

Read more »