Serverless offline for S3 bucket event triggered function


#1

Hi,

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?

Thanks,
Vaughan.


#2

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


#3

You can invoke any function locally with:
sls invoke local -f myFunction -p path/to/data.json -l
or
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.


#4

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