mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
2.4 KiB
2.4 KiB
Read this on the main serverless docs site
Google - Invoke Local
Invokes deployed function locally. It allows to send event data to the function, read logs and display other important information of the function invocation.
serverless invoke local -f functionName
Options
--functionor-fThe name of the function in your service that you want to invoke. Required.--dataor-dData you want to pass into the function--pathor-pPath to JSON or YAML file holding input data. This path is relative to the root directory of the service.--rawPass data as a raw string even if it is JSON. If not set, JSON data are parsed and passed as an object.--contextPathor-x, The path to a json file holding input context to be passed to the invoked function. This path is relative to the root directory of the service.--contextor-c, String data to be passed as a context to your function. Same like with--data, context included in--contextPathwill overwrite the context you passed with--contextflag.--envor-eString representing an environment variable to set when invoking your function, in the form<name>=<value>. Can be repeated for more than one environment variable.
Keep in mind that if you pass both
--pathand--data, the data included in the--pathfile will overwrite the data you passed with the--dataflag.
Examples
Local function invocation
serverless invoke local -f functionName
Local function invocation with data
serverless invoke local -f functionName -d '{ "data": "hello world" }'
Local function invocation with data passing
serverless invoke local -f functionName -p path/to/file.json
# OR
serverless invoke local -f functionName -p path/to/file.yaml
Local function invocation, setting environment variables
serverless invoke local -f functionName -e VAR1=value1
# Or more than one variable
serverless invoke local -f functionName -e VAR1=value1 -e VAR2=value2