You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Shout out to this post for pointing out this workaround:
serverless/serverless-google-cloudfunctions#205 (comment)
Once this is natively supported in the serverless-google-cloudfunctions plugin, the serverless.yml file should be updated accordingly.
Copy file name to clipboardExpand all lines: README.md
+21-13
Original file line number
Diff line number
Diff line change
@@ -2,15 +2,15 @@
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.):
allowUnauthenticated: true # unofficial flag that ties into the post-deploy script
83
78
84
79
...
85
80
</pre>
86
81
82
+
4. Install the serverless plugin dependencies (specified in `package.json`):
83
+
84
+
<pre>
85
+
npm install
86
+
</pre>
87
+
87
88
### Additional info
88
89
89
90
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:
@@ -104,6 +105,13 @@ Run the following command from within your microservice/package directory to rem
104
105
cd <b>mynewservice</b> && serverless remove
105
106
</pre>
106
107
108
+
## Make functions public/private
109
+
110
+
1. In your `serverless.yml` file add the `allowUnauthenticated: true` key to every function you want to allow public access to, and `allowUnauthenticated: false` (or omit it) for every function you want to make/keep private.
111
+
2. From the microservice/package directory run `../scripts/sls-update-allow-unauthenticated.sh`
112
+
113
+
Note: If you want this script to run automatically after every deploy, uncomment the `custom.scripts.commands.hooks` section in the `serverless.yml` file.
0 commit comments