π 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 project demonstrates real-time event-driven architecture using AWS services.
π§± Architecture
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 Code (Python)
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.
https://github.com/IrfanPasha05/s3-file-upload-logger
Top comments (0)