@@ -25,17 +25,29 @@ provider:
25
25
frameworkVersion : ' 3'
26
26
27
27
plugins :
28
+ - serverless-plugin-scripts
28
29
- serverless-google-cloudfunctions
29
30
30
31
# needs more granular excluding in production as only the serverless provider npm
31
32
# package should be excluded (and not the whole node_modules directory)
32
33
package :
33
34
exclude :
34
35
- node_modules/**
36
+ - scripts/**
35
37
- .gitignore
36
38
- .git/**
37
39
38
40
custom :
41
+ scripts :
42
+ # NOTE: uncomment the following if you want the `sls-update-allow-unauthenticated.sh` script to
43
+ # run after every deploy. Otherwise just run the script manually.
44
+ hooks :
45
+ " after:deploy:deploy " : ./scripts/sls-update-allow-unauthenticated.sh
46
+ commands :
47
+ # make the specified function public
48
+ mkfunc-pub : gcloud functions add-iam-policy-binding ${self:service}-${self:provider.stage}-${opt:function, ""} --member="allUsers" --role="roles/cloudfunctions.invoker" --project=${self:provider.project} --region=${self:provider.region}
49
+ # make the specified function private
50
+ mkfunc-pvt : gcloud functions remove-iam-policy-binding ${self:service}-${self:provider.stage}-${opt:function, ""} --member="allUsers" --role="roles/cloudfunctions.invoker" --project=${self:provider.project} --region=${self:provider.region}
39
51
topicName : ${self:service}-gmail-push
40
52
topicResource : projects/${env:GCP_PROJECT}/topics/${self:custom.topicName}
41
53
@@ -44,10 +56,31 @@ functions:
44
56
handler : auth_init
45
57
events :
46
58
- http : true
59
+ accessControl :
60
+ gcpIamPolicy :
61
+ bindings :
62
+ - role : roles/cloudfunctions.invoker
63
+ members :
64
+ - " allUsers"
65
+ # unofficial flag that ties into the post-deploy script; set to false or omit the key if you
66
+ # don't want to make the function public; you will need to run the `sls-update-allow-unauthenticated.sh`
67
+ # script to update the function permissions
68
+ allowUnauthenticated : true
69
+
47
70
auth_callback :
48
71
handler : auth_callback
49
72
events :
50
73
- http : true
74
+ accessControl :
75
+ gcpIamPolicy :
76
+ bindings :
77
+ - role : roles/cloudfunctions.invoker
78
+ members :
79
+ - " allUsers"
80
+ # unofficial flag that ties into the post-deploy script; set to false or omit the key if you
81
+ # don't want to make the function public; you will need to run the `sls-update-allow-unauthenticated.sh`
82
+ # script to update the function permissions
83
+ allowUnauthenticated : true
51
84
52
85
# NOTE: the following uses an "event" event (pubSub event in this case).
53
86
# Please create the corresponding resources in the Google Cloud
0 commit comments