|
2 | 2 |
|
3 | 3 | This template project is designed to be used as a starting point for a Google Cloud Functions project using the Golang runtime and the Serverless Framework.
|
4 | 4 |
|
5 |
| -## Requirements |
| 5 | +## Prerequisites |
6 | 6 |
|
7 |
| -- You have the [Serverless Framework](https://www.serverless.com/framework/docs/getting-started/) installed. |
8 |
| -- You have a project already created and configured in Google Cloud. You can follow [this guide](https://www.serverless.com/framework/docs/providers/google/guide/credentials/) to make sure its setup to work with Severless. |
9 |
| -- You've setup your overall environment to work with GCP and the Serverless Framework. You should follow [these guides](https://www.serverless.com/framework/docs/providers/google/guide/intro/) if not. |
| 7 | +- Install the [Serverless Framework](https://www.serverless.com/framework/docs/getting-started/) |
| 8 | +- Install the [Google Cloud SDK](https://cloud.google.com/sdk/docs/install), and then run `gcloud auth login` to authenticate |
| 9 | +- Create and configure a project in Google Cloud Console. You can follow [this guide](https://www.serverless.com/framework/docs/providers/google/guide/credentials/) to make sure its setup to work with Severless. |
10 | 10 |
|
11 | 11 | ## Project structure
|
12 | 12 |
|
13 |
| -The root directory contains a folder for each of your microservices (i.e. Go package). |
| 13 | +The root directory contains a folder for each microservice/package. |
14 | 14 |
|
15 | 15 | The `go.mod` file also resides in the root directory.
|
16 | 16 |
|
@@ -42,21 +42,15 @@ Create a directory (i.e. package) for each logical microservice you intend to de
|
42 | 42 | cp -R templateservice <b>mynewservice</b>
|
43 | 43 | </pre>
|
44 | 44 |
|
45 |
| -2. Navigate to the new directory and install the Google Cloud Functions Provider Plugin: |
46 |
| - |
47 |
| -<pre> |
48 |
| -cd <b>mynewservice</b> && serverless plugin install --name serverless-google-cloudfunctions |
49 |
| -</pre> |
50 |
| - |
51 |
| -3. Update the package name in both `fn.go` and `fn_test.go` to match your microservice/package name: |
| 45 | +2. Update the package name in both `fn.go` and `fn_test.go` to match your microservice/package name: |
52 | 46 |
|
53 | 47 | <pre>
|
54 | 48 | package <b>mynewservice</b>
|
55 | 49 |
|
56 | 50 | ...
|
57 | 51 | </pre>
|
58 | 52 |
|
59 |
| -4. Open `serverless.yml` and update the configuration (i.e. service name, GCP project name, GCP credentials keyfile, etc.): |
| 53 | +3. Open `serverless.yml` and update the configuration (i.e. service name, GCP project name, GCP credentials keyfile, etc.): |
60 | 54 |
|
61 | 55 | <pre>
|
62 | 56 | service: <b>mynewservice</b>
|
@@ -84,6 +78,12 @@ functions:
|
84 | 78 | ...
|
85 | 79 | </pre>
|
86 | 80 |
|
| 81 | +4. Install the serverless plugin dependencies (specified in `package.json`): |
| 82 | + |
| 83 | +<pre> |
| 84 | +npm install |
| 85 | +</pre> |
| 86 | + |
87 | 87 | ### Additional info
|
88 | 88 |
|
89 | 89 | Take a look at [this guide](https://cloud.google.com/functions/docs/writing#structuring_source_code) for ideas on how to structure your source code for different scenarios:
|
|
0 commit comments