I am trying to pass some 'inputs' into my lambda function on a specific event and am researching ways of doing it. The serverless documentation shows examples of defining an input like such:
serverless.yml
functions:
aggregate:
handler: statistics.handler
events:
- schedule:
rate: rate(10 minutes)
enabled: false
input:
key1: value1
key2: value2
stageParams:
stage: dev
I am still unsure what exactly this is and how it can be accessed (if at all) from my handlers.js function.
If someone could de-mystify this, it would be highly appreciated.
HTTP Trigger Azure Functions has an API endpoint created for each Function App. This service allows you to define public HTTP endpoints for your serverless functions. To create HTTP endpoints as Event sources for your Azure Functions, use the Serverless Framework's easy HTTP Events syntax.
To reference environment variables, use the ${env:SOME_VAR} syntax in your serverless. yml configuration file. It is valid to use the empty string in place of SOME_VAR . This looks like " ${env:} " and the result of declaring this in your serverless.
A Serverless app can simply be a couple of lambda functions to accomplish some tasks, or an entire back-end composed of hundreds of lambda functions. Serverless supports all runtimes offered within the cloud provider chosen. Serverless is developed by Austen Collins and maintained by a full-time team.
An event is a JSON-formatted document that contains data for a Lambda function to process. The Lambda runtime converts the event to an object and passes it to your function code. It is usually of the Python dict type. It can also be list , str , int , float , or the NoneType type.
These values will be passed to your lambda function as part of event object.
nodejs lambda code:
exports.handler = (event, context, callback) =>{
console.log("key1 is", event.key1)
return 0
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With