forked from serverless/serverless
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request serverless#4682 from adnasa/aa-add-GCF-invoke-local
docs(google/cli) add invoke-local.md
- Loading branch information
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<!-- | ||
title: Serverless Framework Commands - Google Cloud Functions - Invoke Local | ||
menuText: invoke local | ||
menuOrder: 7 | ||
description: Emulate an invocation of your Google Cloud function locally using the Serverless Framework | ||
layout: Doc | ||
--> | ||
|
||
<!-- DOCS-SITE-LINK:START automatically generated --> | ||
|
||
### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/google/cli-reference/invoke-local) | ||
|
||
<!-- DOCS-SITE-LINK:END --> | ||
|
||
# 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. | ||
|
||
```bash | ||
serverless invoke -f functionName | ||
``` | ||
|
||
## Options | ||
|
||
* `--function` or `-f` The name of the function in your service that you want to invoke. **Required**. | ||
\_ `--data` or `-d` Data you want to pass into the function | ||
* `--path` or `-p` Path to JSON or YAML file holding input data. This path is relative to the root directory of the service. | ||
* `--raw` Pass data as a raw string even if it is JSON. If not set, JSON data are parsed and passed as an object. | ||
* `--contextPath` or `-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. | ||
* `--context` or `-c`, String data to be passed as a context to your function. Same like with `--data`, context included in `--contextPath` will overwrite the context you passed with `--context` flag. | ||
|
||
> Keep in mind that if you pass both `--path` and `--data`, the data included in the `--path` file will overwrite the data you passed with the `--data` flag. | ||
## Examples | ||
|
||
### Local function invocation | ||
|
||
```bash | ||
serverless invoke local -f functionName | ||
``` | ||
|
||
### Local function invocation with data | ||
|
||
```bash | ||
serverless invoke local -f functionName -d '{ "data": "hello world" }' | ||
``` | ||
|
||
### Local function invocation with data passing | ||
|
||
```bash | ||
serverless invoke local -f functionName -p path/to/file.json | ||
|
||
# OR | ||
|
||
serverless invoke local -f functionName -p path/to/file.yaml | ||
``` |