AWS Lambda function which fetches data from MongoDB, notifying MyGovHub users about upcoming & overdue bill payments or documentation renewal reminders. Setup includes 2 seperate AWS Lambda functions.
© 2025 Goodbye World team, for Great AI Hackathon Malaysia 2025 usage.
lambda_functions/
get_notification/
get_notifications.py
requirements.txt
lambda_notification/
lambda_notification.py
requirements.txt
.gitignore
README.md
requirements.txt
- Purpose: Scans MongoDB for overdue/upcoming bills and licenses, and inserts notifications.
- Location:
lambda_functions/lambda_notification/lambda_notification.py - Handler:
lambda_notification.lambda_handler
- Purpose: API endpoint to fetch notifications for a user (for frontend).
- Location:
lambda_functions/get_notification/get_notifications.py - Handler:
get_notifications.lambda_handler
-
Create Lambda Layer
- Build a layer with
pymongo==4.5.0,dnspython==2.4.2, andpytz. - Do NOT commit the
python/folder orlayer.zipto Git. - Attach this layer to both Lambda functions.
- Build a layer with
-
Deploy Lambda Functions
- Zip only the
.pyfile for each function (not the folder). - Set the handler as shown above.
- Set the environment variable
MONGO_SECRET_ARNto your Secrets Manager ARN.
- Zip only the
-
API Gateway (for get_notification)
- Create a REST API.
- Connect the GET method to the
get_notificationLambda. - Example endpoint:
GET /notifications?user_name=Alice%20Tan
-
MongoDB Atlas
- Store your connection string in AWS Secrets Manager as a JSON key
AtlasMongo. - Whitelist Lambda’s IP or use
0.0.0.0/0for testing.
- Store your connection string in AWS Secrets Manager as a JSON key
Your .gitignore is set up to ignore:
- Python cache, virtualenvs
- Lambda layer build artifacts (
python/,layer.zip) - OS/editor files