Serverless offline for S3 bucket event triggered function



This is probably a silly question, as I am somewhat new to Serverless.

Is it possible to test/run an S3 bucket event triggered Serverless function locally? I get the impression offline is great for testing functions that handle web requests, but it would be very difficult to test a function that reacts to the placing of a file in an S3 bucket locally?



i am having the same issue right now, did you come to any solution?


You can invoke any function locally with:
sls invoke local -f myFunction -p path/to/data.json -l
sls invoke local -f myFunction -d '{ myEvent:content }'

Look here for the AWS S3 Event Message Structure

And here for Sample S3 Events

Or if you have a function deployed, you can console.log(event) as the first line of your function and capture an actual event as it fires.


serverless-s3-local may help you. This plugin supports s3 events to start lambda functions. Please see the simple_event example.