serverless-s3-local icon indicating copy to clipboard operation
serverless-s3-local copied to clipboard

No Events are triggered

Open oneandonlyoddo opened this issue 7 years ago • 7 comments

I tried to use this plugin to trigger events locally but failed to do so. So I went along ant tried the examples. Creating buckets and listing their contents seem to work fine. But neither the simple_event nor the resize_image triggered and event for me. No errors in the console either. I simply ran npm install and started everything with sls offline start. Did I miss something?

oneandonlyoddo avatar Aug 20 '18 18:08 oneandonlyoddo

Hi @oneandonlyoddo Thanks for your comment. I'm sorry for unhelpful document about this functions. I ran simple_event and resize_image and then they worked correctly. Please check the following steps.

  1. Start serverless-offline in terminal-1
$ sls offline start
(node:1952) ExperimentalWarning: The fs.promises API is experimental
Serverless: Found S3 event listener for local-bucket
S3 local started ( port:8000 )
Serverless: creating bucket: local-bucket
info: [S3rver] Created new bucket "local-bucket" successfully
info: [S3rver] PUT /local-bucket 200 - - 5.385 ms
Serverless: Starting Offline: dev/us-east-1.

Serverless: Routes for webhook:
Serverless: GET /

Serverless: Routes for s3hook:
Serverless: (none)

Serverless: Offline listening on http://localhost:3000
  1. Put a file(handler.js) to s3rver in terminal-2
$ aws --endpoint http://localhost:8000 s3api put-object --bucket local-bucket --key handler.js --body ./handler.js
  1. Trigger event and print event description in terminal-1
info: [S3rver] Stored object "handler.js" in bucket "local-bucket" successfully
{"Records":[{"eventVersion":"2.0","eventSource":"aws:s3","awsRegion":"us-east-1","eventTime":null,"eventName":"ObjectCreated:Put","userIdentity":{"principalId":"AWS:6C1B826971F99672D08E5"},"requestParameters":{"sourceIPAddress":"127.0.0.1
"},"responseElements":{"x-amz-request-id":"AEB4C4E7EB5FE9F3","x-amz-id-2":"WviFkakBm0CFCVbyeIKQwv5OOD5sBWGTTzv9gA+b3S8="},"s3":{"s3SchemaVersion":"1.0","configurationId":"testConfigId","bucket":{"name":"local-bucket","ownerIdentity":{"pri
ncipalId":"A9FF8740B4D4CC"},"arn":"arn:aws:s3: : :local-bucket"},"object":{"key":"handler.js","sequencer":"16559377262","size":470,"eTag":"d4fe0d10cfa807f4607db17fb12cb2e4"}}}]}
{"functionName":"serverless-s3-local-example-dev-s3hook","functionVersion":"offline_functionVersion_for_serverless-s3-local-example-dev-s3hook","invokedFunctionArn":"offline_invokedFunctionArn_for_serverless-s3-local-example-dev-s3hook","
awsRequestId":"offline_awsRequestId_05343422780009455","logGroupName":"offline_logGroupName_for_serverless-s3-local-example-dev-s3hook","logStreamName":"offline_logStreamName_for_serverless-s3-local-example-dev-s3hook","identity":{},"clie
ntContext":{}}  
info: [S3rvtr] PUTp/locgl-bucket/handler.js 200 - - 9.701 ms

If you have any question, please let me know !

ar90n avatar Aug 20 '18 21:08 ar90n

Hey @ar90n, Thanks for the quick response. Really appreciated.I didn't knew I had to use the aws s3api put-object command. I was literally just dragging files into the local-bucket. Using the aws cli events are now correctly triggered. However if I try the image_resize example and upload an image to the local-bucket only a folder with the name of the image is created instead of putting the actual file. Uploading in the same way to a bucket on Amazon works.

oneandonlyoddo avatar Aug 21 '18 10:08 oneandonlyoddo

Hi @oneandonlyoddo In the image_resize example, we have to put the original image to /incoming and get the resized image from /processed by using aws cli. Please refer the following commands.

Put the original image to /incoming

aws --endpoint http://localhost:8000 s3api put-object --bucket local-bucket --key incoming/test.jpg --body ./test.JPG

Get the resized image from /processed

aws --endpoint http://localhost:8000 s3api get-object --bucket local-bucket --key processed/test.jpg test.jpg

ar90n avatar Aug 21 '18 17:08 ar90n

I found this page after a few hours of debugging. This info is critical to have in the README. Please add this.

cpvandehey avatar Nov 20 '18 01:11 cpvandehey

@cpvandehey Feel free to send a pull request that adds this info to the readme 😊

n1ru4l avatar Nov 20 '18 13:11 n1ru4l

Will do.

Also, and for lack of a better thread/laziness, does this plugin support python runtimes? I had some issues yesterday that I might try to fix today to support my python handlers (the errors show up when invoking from an s3 event).

On Tue, Nov 20, 2018, 5:42 AM Laurin Quast <[email protected] wrote:

@cpvandehey https://github.com/cpvandehey Feel free to send a pull request that adds this info to the readme 😊

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ar90n/serverless-s3-local/issues/39#issuecomment-440277310, or mute the thread https://github.com/notifications/unsubscribe-auth/AHnA9KDDnEYGXwVe0eVIUKJjGPKg34v1ks5uxAawgaJpZM4WEfnh .

cpvandehey avatar Nov 20 '18 16:11 cpvandehey

@cpvandehey I’m sorry for poor documentations. Your suggestion is quite correct !! If you send me a pull request about this issue, I’ll merged it ! It’ll make me happy. If you don’t have enought time, please let me know. In case of that, I’ll update some README.md.

@n1ru4l Thanks for your great advice !

ar90n avatar Nov 22 '18 00:11 ar90n