This project demonstrates an end-to-end flow of how to automatically process file uploads to an S3 bucket using an AWS Lambda function, and subsequently notify a user through email using Amazon Simple Notification Service (SNS). It is entirely automated by a shell script which creates the necessary resources and sets up the necessary permissions and triggers.
The project makes use of several AWS services including S3, Lambda, SNS, IAM, and STS, as well as third-party tools like jq
for processing JSON data, and is written using Bash and Python scripting languages.
The project follows this flow:
- A user uploads a file to an S3 bucket.
- This triggers an AWS Lambda function that is set to listen for the 'ObjectCreated' event from this specific S3 bucket.
- The Lambda function processes the event, then publishes a message to an SNS topic.
- An email is then sent to the subscribed email address containing the message from the SNS topic.
This entire workflow is set up using a shell script which does the following:
- Creates an IAM role for the Lambda function.
- Attaches necessary policies to the role.
- Creates the S3 bucket.
- Creates the Lambda function and uploads the Python script.
- Sets the Lambda function to be triggered by 'ObjectCreated' events from the S3 bucket.
- Creates the SNS topic.
- Subscribes an email address to the SNS topic.
To set up and execute this project, run the shell script s3-notification-triggers.sh
from your terminal:
$ chmod +x ./s3-notification-triggers.sh
$ ./s3-notification-triggers.sh
Ensure that you have AWS CLI installed and configured with your AWS account credentials, and that you have 'jq' installed for processing JSON data.
Two screenshots have been added to this repository to show the functioning of this project.
- email_notification.png: This screenshot shows the email received when a new object was added to the S3 bucket
- lambda_console.png: This screenshot shows the Lambda console with the function overview, displaying the trigger event with the S3 bucket.