Lambda function is not called when the file is uploaded to S3

1.5k Views Asked by At

I am developing a web application which uses service services from AWS. I am storing my files on the s3 bucket. What I am trying to do is when I upload the file to the S3 bucket, I want a lambda function to be automatically triggered to resize the image. I created a lambda function and test it using the console. It is working. As you can see in the screenshot.

enter image description here

The image is actually resized in the bucket and created as a new file as well. Then from the Laravel application, I upload an image like this.

$path =$request->file('file')->store(
      "path", 's3'
);

The image is uploaded to the s3 bucket. But the event is not triggered to create resize it. But why it is not working? Actually, that lambda function is supposed to be triggered automatically when an object is created in the bucket. But it is not working. But the function is working when I run it from the console using the test option.

What is the possible configuration I am missing to get it working? Do I need to call that lambda function manually in my code? But it is supposed to be triggered automatically when the file is uploaded. Is it? What can be the possible issue?

This is my policy on S3 Bucket:

enter image description here

Here is my s3 bucket event configuration

enter image description here

0

There are 0 best solutions below