mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
Merge pull request #3645 from serverless/update-google-function-docs
Update Google Cloud Function docs to reflect recent changes
This commit is contained in:
commit
6e654981ce
@ -37,16 +37,3 @@ The Serverless Framework translates all syntax in `serverless.yml` to a Google D
|
||||
- Use this in your CI/CD systems, as it is the safest method of deployment.
|
||||
|
||||
Check out the [deploy command docs](../cli-reference/deploy.md) for all details and options.
|
||||
|
||||
## Deploying a package
|
||||
|
||||
This deployment option takes a deployment directory that has already been created with `serverless package` and deploys it to the cloud provider. This allows you to easier integrate CI / CD workflows with the Serverless Framework.
|
||||
|
||||
```bash
|
||||
serverless deploy --package path-to-package
|
||||
```
|
||||
|
||||
### How It Works
|
||||
|
||||
- The argument to the `--package` flag is a directory that has been previously packaged by Serverless (with `serverless package`).
|
||||
- The deploy process bypasses the package step and uses the existing package to deploy and update DeploymentManager deployments.
|
||||
|
||||
@ -35,29 +35,24 @@ functions:
|
||||
- http: path
|
||||
```
|
||||
|
||||
The `handler` property points to the file (default filename: index.js) and module containing the code you want to run in your function.
|
||||
## Handler
|
||||
|
||||
The `handler` property should be the function name you've exported in your entrypoint file.
|
||||
|
||||
When you e.g. export a function with the name `http` in `index.js` your `handler` should be `handler: http`.
|
||||
|
||||
```javascript
|
||||
// index.js
|
||||
exports.http = (request, response) => {}
|
||||
```
|
||||
|
||||
**Note:** The file which contains the handlers needs to have the name `index.js`.
|
||||
**A note about index.js and the entrypoint file**
|
||||
|
||||
You can add as many functions as you want within this property.
|
||||
Google Cloud Functions assumes that you have a `index.js` or `function.js` file with the exported handler functions in the root of your project (you can read more about that in [their docs](https://cloud.google.com/functions/docs/deploying/)).
|
||||
|
||||
```yml
|
||||
# serverless.yml
|
||||
...
|
||||
However you can overwrite this by specifying the entrypoint file with the help of the `main` config parameter in the projects `package.json` file.
|
||||
|
||||
functions:
|
||||
functionOne:
|
||||
handler: http
|
||||
functionTwo:
|
||||
handler: http
|
||||
functionThree:
|
||||
handler: otherHandler
|
||||
```
|
||||
Our recommendation is to have an `index.js` file with all the function handlers in the projects root directory.
|
||||
|
||||
## Memory size and timeout
|
||||
|
||||
|
||||
@ -21,9 +21,3 @@ Running the following command will build and save all of the deployment artifact
|
||||
```bash
|
||||
serverless package
|
||||
```
|
||||
|
||||
However, you can also use the --package option to add a destination path and Serverless will store your deployment artifacts there (./my-artifacts in the following case):
|
||||
|
||||
```bash
|
||||
serverless package --package my-artifacts
|
||||
```
|
||||
|
||||
@ -56,6 +56,7 @@ Check out the [create command docs](../cli-reference/create) for all the details
|
||||
## Contents
|
||||
|
||||
You'll see the following files in your working directory:
|
||||
|
||||
- `serverless.yml`
|
||||
- `index.js`
|
||||
|
||||
@ -93,7 +94,7 @@ functions:
|
||||
|
||||
### index.js
|
||||
|
||||
The `index.js` file contains your function code. The function definition in `serverless.yml` will point to this `index.js` file and the function exported here.
|
||||
The `index.js` file contains your exported functions.
|
||||
|
||||
## Deployment
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user