The purpose of this post is nothing else just make an overview of interaction between AWS Lambda and AWS S3. You can easily search on the Internet about the information about what AWS Lambda and AWS S3 are, I just wanna make it understandable in an easy way like below:

 

In this post, I am going to show you the prototype of interaction between AWS Lambda and AWS S3. The testing procedure is below:

  • Create two buckets in the AWS S3:

  • - Source bucket called “tutj” where I store an image called “cover.jpeg”

    cover

    Picture 1. cover.jpeg

    - Destination bucket called “tutjresized” where I am going to nothing else just copy that image “cover.jpeg”. Actually, you can do anything you want with image (resize, change color, etc.) then store it to the destination bucket.

    S3_bucket

    Picture 2. AWS S3 buckets

    Function-name: “CopyImage”

    Source code and dependencies: “/home/ubuntu/CopyImage.zip”

    Handler: “CopyImage.handler”. It will be called each time AWS S3 triggers AWS Lambda.

    Profile: “tutj”. The AWS User.

    $ sudo aws lambda create-function --region us-east-1 --function-name CopyImage –zip-file fileb:///home/ubuntu/CopyImage.zip –role arn:aws:iam::856421922278:role/lambda-s3-execution-role --handler CopyImage.handler --runtime python2.7 --profile tutj --timeout 10

    Lambda_function

    Picture 3. AWS Lambda CopyImage function

     

    tutjresized

    Picture 4. Image in the destination bucket

     

    For more information, follow this below link on AWS:

    http://docs.aws.amazon.com/lambda/latest/dg/with-s3.html