Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to push test events to AWS Lambda with the Serverless Framework?

I'm using the Serverless Framework to push to AWS Lambda. To test my functions, I'm currently just using the Lambda console to add each method, which is getting rather tedious, and I would like to have a way to push them along side with the code with serverless deploy.

enter image description here

I've found this reference on the Serverless method for testing locally, but it doesn't seem to deploy those test events to Lambda.

Ideally, I'd like to be able to to do this in Serverless, but if there a way to do it via aws-cli it might be a good option too.

like image 966
cchapman Avatar asked Nov 04 '18 14:11

cchapman


Video Answer


1 Answers

Unfortunately the test events are a feature of the AWS console alone, and are not made available on the AWS API (docs).

As you've noticed, the Serverless Framework includes invocation commands- you've linked to Invoke Local, but Invoke also exists, which invokes your function, on the cloud, just like the AWS console.

As Serverless' Invoke command can take a JSON file as an event, a work around I might suggest is to create a folder (like tests/payloads) of JSONs events as part of your code. That way you can then use serverless invoke -f functionName -p ./tests/payloads/payloadName.json to emulate the experience the AWS Console gives you.

like image 188
thomasmichaelwallace Avatar answered Oct 18 '22 19:10

thomasmichaelwallace