Trigger a function in AWS Lambda on uploading a file

- Log in to your AWS account and on the dashboard, search for Lambda

Click on Lambda, and you will land on the Lambda dashboard. Click on “Create a function”.

Choose a function name, select a runtime that you are comfortable with. Leave everything else the same and click on create function on the bottom right

Add a trigger

Select source as S3. Then choose a bucket name and select event type as PUT if you want to trigger the function on image upload. Enter a suffix if you want a particular type of image to trigger the event

Lambda needs permission to read from the S3 bucket. Go to configuration and click on permissions, then under click on role name.

Click on add permission → Create Inline policy

Add Permission. Click on Actions and import policy, and search for “AWSLambdaBasicExecutionRole” and add it. Save

Now, upload an image to S3 and go to your Lambda console → Monitor → View CloudWatch logs



