2

I found a plugin: https://www.npmjs.com/package/serverless-offline

But it emulates AWS lambda. I write a HTTP function and test it, print out the second argument of the function:

res: {"functionName":"cedar-cloud-functions-dev-sendEmail","functionVersion":"offline_functionVersion_for_cedar-cloud-functions-dev-sendEmail","invokedFunctionArn":"offline_invokedFunctionArn_for_cedar-cloud-functions-dev-sendEmail","awsRequestId":"offline_awsRequestId_23960008909951136","logGroupName":"offline_logGroupName_for_cedar-cloud-functions-dev-sendEmail","logStreamName":"offline_logStreamName_for_cedar-cloud-functions-dev-sendEmail","identity":{},"clientContext":{}}

As you can see, there is an awsRequestId property, so this second argument should be the context in AWS lambda, not the res in GCF.

Is there a plugin emulates google cloud function on the local machine?

slideshowp2
  • 38,463
  • 29
  • 127
  • 255
  • Found the same post here: https://forum.serverless.com/t/testing-gcp-functions/4585, but sadly, there is no answer for it. – slideshowp2 May 03 '19 at 04:36
  • Running a GCF locally should be possible. There is an [emulator](https://cloud.google.com/functions/docs/emulator) but it is discontinued in favored of [Functions Framework](https://cloud.google.com/functions/docs/functions-framework). You will just need to spin a local server and follow the instructions there. It is not clear what is your question about context and about the plugin. You should provide references. Finally, you seem to have provided some output there. Is that what your function returns when it works locally using AWS? – K F Jun 29 '19 at 05:43

0 Answers0