|
4 | 4 |
|
5 | 5 | This plugin enables support for [Google Cloud Functions](https://cloud.google.com/functions/) within the [Serverless Framework](https://github.com/serverless/serverless).
|
6 | 6 |
|
7 |
| -## Getting started |
| 7 | +## Documentation |
8 | 8 |
|
9 |
| -This guide will help you setup a Google Cloud Project (required) and your first Google Cloud Functions. |
10 |
| - |
11 |
| -### Create a Serverless Service with Google as the Provider |
12 |
| - |
13 |
| -Google support for the `create` command is coming soon. Until then, follow these steps: |
14 |
| - |
15 |
| -1. Run `serverless install --url https://github.com/serverless/boilerplate-googlecloudfunctions-nodejs --name <my-service>` |
16 |
| -2. `cd <my-service> && npm install` |
17 |
| -3. Rename the `service` property in `serverless.yml` (make sure the name does not include "google" or "goog") |
18 |
| - |
19 |
| -### Set up Google Cloud Platform |
20 |
| - |
21 |
| -#### Create a Google Cloud Billing Account |
22 |
| - |
23 |
| -You need a Billing Account with a credit card attached to use Google Cloud Functions. Here's how to create one: |
24 |
| - |
25 |
| -1. <a href="https://console.cloud.google.com/billing/create" target="_blank">Click here</a>, to go to the screen to create a new Billing Account. |
26 |
| -2. Enter the name of the Billing Account and enter your billing information. Then click Submit to enable billing. |
27 |
| -3. A Billing Account will exist already offering you a free trial. Please note that this will not work for Google Cloud Functions. Only a Billing Account with a valid credit card will work. |
28 |
| - |
29 |
| -If necessary, a more detailed guide on creating a Billing Account can be found <a href="https://support.google.com/cloud/answer/6288653?hl=en" target="_blank">here</a>. |
30 |
| - |
31 |
| -#### Create a new Google Cloud Project |
32 |
| - |
33 |
| -A Google Cloud Project is required to use Google Cloud Functions. Here's how to create one: |
34 |
| - |
35 |
| -1. Go to the <a href="https://console.cloud.google.com" target="_blank">Google Cloud Console Console</a>. |
36 |
| -2. There is a dropdown near the top left of the screen (near the search bar that lists your projects). Click it and select "Create Project". |
37 |
| -3. Enter a Project name and select the Billing Account you created in the steps above (or any Billing Account with a valid credit card attached). |
38 |
| -3. Click on "Create" to start the creation process. |
39 |
| -4. Wait until the Project was successfully created and Google will redirect you to your new Project. |
40 |
| -5. Verify your currently within your new Project by looking at the dropdown next to the search bar. This should mark your new Project as selected. |
41 |
| - |
42 |
| -#### Enable the necessary APIs |
43 |
| - |
44 |
| -You need to enable the following APIs so that Serverless can create the corresponding resources. |
45 |
| - |
46 |
| -Go to the <a href="https://console.cloud.google.com/apis/dashboard" target="_blank">API dashboard</a>, select your project and enable the following APIs (if not already enabled): |
47 |
| - |
48 |
| -- Google Cloud Functions |
49 |
| -- Google Cloud Deployment Manager |
50 |
| -- Google Cloud Storage |
51 |
| -- Stackdriver Logging |
52 |
| - |
53 |
| -#### Get credentials |
54 |
| - |
55 |
| -You need to create credentials Serverless can use to create resources in your Project. |
56 |
| - |
57 |
| -1. Go to the <a href="https://console.cloud.google.com/apis" target="_blank">Google Cloud API Manager</a> and select "Credentials" on the left. |
58 |
| -2. Click on "Create credentials" and select "Service account key". |
59 |
| -3. Select "New service account" in the "Service account" dropdown. |
60 |
| -4. Enter a name for your "Service account name" (e.g. "serverless-framework"). |
61 |
| -5. Select "Project" --> "Owner" as the "Role". |
62 |
| -6. The "Key type" should be "JSON". |
63 |
| -7. Click on "Create" to create your private key. |
64 |
| -8. That's your so called `keyfile` which should be downloaded on your machine. |
65 |
| -9. Save the `keyfile` somewhere secure. We recommend making a folder in your root folder and putting it there. Like this, `~/.gcloud/keyfile.json`. You can change the file name from `keyfile` to anything. Remember the path you saved it to. |
66 |
| - |
67 |
| -### Update the `provider` config in `serverless.yml` |
68 |
| - |
69 |
| -Open up your `serverless.yml` file and update the `provider` section with your Google Cloud Project id and |
70 |
| -the path to your `keyfile.json` file (this path needs to be absolute!). It should look something like this: |
71 |
| - |
72 |
| -```yml |
73 |
| -provider: |
74 |
| - name: google |
75 |
| - runtime: nodejs |
76 |
| - project: my-serverless-project-1234 |
77 |
| - credentials: ~/.gcloud/keyfile.json |
78 |
| -``` |
79 |
| -
|
80 |
| -## Workflow |
81 |
| -
|
82 |
| -**Note:** The `<function-name>` is the corresponding name in `serverless.yml` |
83 |
| - |
84 |
| -1. Deploy the service with `serverless deploy` |
85 |
| -2. Invoke a function with `serverless invoke -f <function-name>` |
86 |
| -3. View the function logs with `serverless logs -f <function-name>` |
87 |
| -4. See information about the service with `serverless info` |
88 |
| -5. Remove the service with `serverless remove` |
| 9 | +The documentation can be found [here](https://serverless.com/framework/docs/providers/google). |
89 | 10 |
|
90 | 11 | ---
|
91 | 12 |
|
|
0 commit comments