A serverless inventory monitoring solution that automatically detects low-stock products and sends email alerts using AWS services.
This project demonstrates a simple yet practical serverless architecture on AWS. When a CSV inventory file is uploaded to an S3 bucket, a Lambda function automatically processes it, identifies products with stock levels below their minimum threshold, and sends an email notification via SNS.
Author: nijordia
Flow:
- Clerk uploads
inventory.csvto S3 bucket - S3 event triggers Lambda function
- Lambda reads CSV and checks:
current_stock < min_stock - If low stock items found → Lambda publishes alert to SNS
- SNS sends email notification to suppliers & manager
| Service | Purpose |
|---|---|
| Amazon S3 | Stores uploaded inventory CSV files and triggers Lambda on new uploads |
| AWS Lambda | Serverless compute that processes CSV files and checks stock levels |
| Amazon SNS | Sends email notifications when low stock is detected |
| AWS CloudFormation | Infrastructure as Code for deploying all resources |
| Python 3.12 | Lambda runtime for processing logic |
- Deploy stack (via Console or CLI)
- Confirm SNS subscription in your inbox
- Upload
example_inventory.csvto the bucket - Check email for low stock alert
- AWS Account with appropriate permissions
- AWS CLI installed and configured
- Email address for receiving alerts (you'll need to confirm the subscription)
git clone https://github.com/nijordia/aws-inventory-pipeline.git
cd aws-inventory-pipelineUsing AWS CLI:
aws cloudformation create-stack \
--stack-name inventory-alert-pipeline \
--template-body file://cloudformation-template.yaml \
--parameters \
ParameterKey=BucketNamePrefix,ParameterValue=my-inventory \
ParameterKey=AlertEmail,ParameterValue=your-email@example.com \
--capabilities CAPABILITY_IAMUsing AWS Console:
- Navigate to CloudFormation in the AWS Console
- Click Create stack → With new resources
- Upload
cloudformation-template.yaml - Fill in the parameters:
BucketNamePrefix: A unique prefix for your S3 bucketAlertEmail: Your email address for receiving alerts
- Acknowledge IAM resource creation
- Click Create stack
After deployment, check your email inbox for a subscription confirmation from AWS SNS. Click the confirmation link to activate alerts.
Upload the example CSV to your S3 bucket:
aws s3 cp example_inventory.csv s3://<your-bucket-name>/inventory.csvOr upload via the AWS Console S3 interface.
The inventory CSV must have the following columns:
| Column | Description |
|---|---|
product |
Product name or identifier |
current_stock |
Current quantity in stock |
min_stock |
Minimum threshold for alerts |
Example:
product,current_stock,min_stock
Widget A,50,20
Widget B,5,10
Gadget X,100,25Stack successfully deployed with CREATE_COMPLETE status, showing all resources provisioned:
Email received to confirm subscription to the alert topic:
Alert triggered after uploading inventory CSV with items below minimum stock:
aws-inventory-pipeline/
├── README.md # Project documentation
├── cloudformation-template.yaml # IaC template for all AWS resources
├── lambda_code/
│ └── inventory_alert.py # Lambda function source code
├── example_inventory.csv # Sample CSV for testing
├── images/
│ └── diagram.png # Architecture diagram
└── screenshots/ # Documentation screenshots
├── CloudFormation.png
├── SNS_suscription.png
└── Email _alert.png
-
S3 Event Notification: When a
.csvfile is uploaded to the S3 bucket, an event notification triggers the Lambda function. -
CSV Processing: The Lambda function:
- Downloads the CSV file from S3
- Parses each row to extract product, current_stock, and min_stock
- Identifies products where
current_stock < min_stock
-
Alert Generation: If low-stock products are found:
- Formats a human-readable alert message
- Publishes the message to the SNS topic
- SNS delivers the email to all confirmed subscribers
-
Error Handling: The Lambda function includes error handling for:
- Invalid CSV format
- Missing columns
- Non-numeric stock values
- S3 access issues
This solution uses AWS Free Tier eligible services:
- S3: 5GB storage, 20,000 GET requests, 2,000 PUT requests/month free
- Lambda: 1M requests, 400,000 GB-seconds/month free
- SNS: 1,000 email notifications/month free
For typical inventory monitoring usage, this solution should operate within the Free Tier.
To delete all resources and avoid charges:
# First, empty the S3 bucket
aws s3 rm s3://<your-bucket-name> --recursive
# Then delete the CloudFormation stack
aws cloudformation delete-stack --stack-name inventory-alert-pipeline- Add DynamoDB for historical tracking
- Implement multiple alert thresholds (warning/critical)
- Add Slack/Teams webhook integration
- Create a web dashboard with API Gateway
- Add support for Excel files
MIT License - feel free to use this project for learning or as a starting point for your own solutions.
Questions or feedback? Open an issue on GitHub.



