Lambda function to sort the objects uploaded to main bucket into different buckets according to formats. Added CloudWatch and SNS functionality.
(Amazon S3, Lambda, CloudWatch, SNS, python)
Prerequisites:
-
Create a role with AWS S3 full access and AWS CloudWatch full access.
-
Create 4 buckets
• Main bucket where objects are uploaded
• Txt, pdf, img bucket to store the objects after sorting accordingly.
Steps:
-
Create a lambda function. Remember to give the same name as main s3 bucket created since the code takes the bucket name from the lambda function itself.
-
Add a trigger as S3 bucket by selecting the main bucket.
-
Add Destination as SNS topic
-
Add the code and deploy.
-
Now whenever there is an object uploaded into main bucket, it will be moved to another bucket according to the format.