# Serverless offline for S3 bucket event triggered function

**URL:** <https://forum.serverless.com/t/serverless-offline-for-s3-bucket-event-triggered-function/4307>\
**Category:** Serverless Framework\
**Created:** [April 20, 2018, 9:14am UTC](https://forum.serverless.com/t/serverless-offline-for-s3-bucket-event-triggered-function/4307 "2018-04-20T09:14:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![VaughanJackson](https://avatars.discourse-cdn.com/v4/letter/v/58956e/32.png) [@VaughanJackson](https://forum.serverless.com/u/VaughanJackson)\
**Post date:** [April 20, 2018, 9:14am UTC](https://forum.serverless.com/t/serverless-offline-for-s3-bucket-event-triggered-function/4307/1 "2018-04-20T09:14:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JuHwon](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/juhwon/32/2014_2.png) [@JuHwon](https://forum.serverless.com/u/JuHwon)\
**Post date:** [May 28, 2018, 2:14pm UTC](https://forum.serverless.com/t/serverless-offline-for-s3-bucket-event-triggered-function/4307/2 "2018-05-28T14:14:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bfieber](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/bfieber/32/653_2.png) [@bfieber](https://forum.serverless.com/u/bfieber)\
**Post date:** [May 28, 2018, 6:13pm UTC](https://forum.serverless.com/t/serverless-offline-for-s3-bucket-event-triggered-function/4307/3 "2018-05-28T18:13:26Z")

</div>

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](https://docs.aws.amazon.com/AmazonS3/latest/dev/notification-content-structure.html)

And here for [Sample S3 Events](https://docs.aws.amazon.com/lambda/latest/dg/eventsources.html#eventsources-s3-put)

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.

---

<div class="post-metadata">

**Author:** ![ar90n](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/ar90n/32/2222_2.png) [@ar90n](https://forum.serverless.com/u/ar90n)\
**Post date:** [July 11, 2018, 1:26pm UTC](https://forum.serverless.com/t/serverless-offline-for-s3-bucket-event-triggered-function/4307/4 "2018-07-11T13:26:51Z")

</div>

[serverless-s3-local](https://github.com/ar90n/serverless-s3-local) may help you. This plugin supports s3 events to start lambda functions. Please see the simple\_event example.
