dherault / serverless-offline

Emulate AWS λ and API Gateway locally when developing your Serverless project
MIT License
5.19k stars 795 forks source link

Offline SNS to invoke lambda #235

Closed schassande closed 5 years ago

schassande commented 7 years ago

Is it possible to add the support of lambda invocation by a sns message in offline mode ?

dherault commented 7 years ago

Hi @schassande , how would you do that ?

schassande commented 7 years ago

Hi,

I would like to run my AWS application on the developer's computer in offline mode. Today I can do it with the great dynamoDB offline plugin. I wish the same thing for the lambda invocation by SNS and the S3 bucket access. How to do that .. ? I don't know. But I imagine a dummy local SNS service which doesn't send the message to the AWS service but calls the lambdas having the sns topic as trigger. The perfect solution should an async call.

Seb

breathe commented 7 years ago

I'm wondering about the same thing for proxying requests from Amazon Lex Lambda handlers to a local server. I want the benefit to quickly change the lambda handler code during development more than I care about offline capability...

Maybe we could deploy a lambda function to the service endpoint which proxies invocations through to the laptop server ...?

Would such an implementation fit into serverless-offline?

btburton42 commented 7 years ago

I'm wondering the same thing. Our current project is using the serverless-webpack plugin and I'm having success invoking it with sls webpack invoke, passing the function name and the invocation event as parms. I even have it working in VS Code so you get breakpoint stepping which is super nice.

It would be great to see an example of this working with serverless-offline. (My big disconnect is that I'm using an event trigger and not an API Gateway call and AFAIK that's not supported in serverless offline (??)).

I've also had success doing this with the npm module lambda-local if you aren't doing anything fancy with webpack.

TrentBartlem commented 6 years ago

https://www.npmjs.com/package/serverless-offline-sns ?

brentpabst commented 4 years ago

The serverless-offline-sns plugin doesn't support all of the runtimes supported by the base serverless-offline plugin. It only supports node as a runtime right now. That plugin simply exposes HTTP endpoints to invoke the functions and handles the subscription and setup of SNS topics automatically on a local SNS-compatible interface. Would propose that this functionality should live in serverless-offline to support the SNS event trigger. Could likely be expanded to support SQS and others too. Any chance we can iterate on a design for this?

throrin19 commented 1 year ago

I relaunch this topic : serverless-offline-sns is no longer maintained and not compatible with verserless v3.

In addition, it is not fully compatible with localstack: error when adding the subscription.

I think it's necessary either to remake a new serverless-offline-sns module from scratch, or to finally make this part fully compatible directly within serverless-offline.