@@ -25,29 +25,64 @@ 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 :
39
41
topicName : ${self:service}-gmail-push
40
42
topicResource : projects/${env:GCP_PROJECT}/topics/${self:custom.topicName}
43
+ scripts :
44
+ # NOTE: uncomment the following if you want the `sls-update-allow-unauthenticated.sh` script to
45
+ # run after every deploy. Otherwise just run the script manually.
46
+ hooks :
47
+ " after:deploy:deploy " : ./scripts/sls-update-allow-unauthenticated.sh
48
+ commands :
49
+ # make the specified function public
50
+ 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}
51
+ # make the specified function private
52
+ 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}
41
53
42
54
functions :
43
55
auth_init :
44
56
handler : auth_init
45
57
events :
46
58
- http : true
59
+ # TODO: Grant public access
60
+ accessControl :
61
+ gcpIamPolicy :
62
+ bindings :
63
+ - role : roles/cloudfunctions.invoker
64
+ members :
65
+ - " allUsers"
66
+ # unofficial flag that ties into the post-deploy script; set to false or omit the key if you
67
+ # don't want to make the function public; you will need to run the `sls-update-allow-unauthenticated.sh`
68
+ # script to update the function permissions
69
+ allowUnauthenticated : true
70
+
47
71
auth_callback :
48
72
handler : auth_callback
49
73
events :
50
74
- http : true
75
+ # TODO: Grant public access
76
+ accessControl :
77
+ gcpIamPolicy :
78
+ bindings :
79
+ - role : roles/cloudfunctions.invoker
80
+ members :
81
+ - " allUsers"
82
+ # unofficial flag that ties into the post-deploy script; set to false or omit the key if you
83
+ # don't want to make the function public; you will need to run the `sls-update-allow-unauthenticated.sh`
84
+ # script to update the function permissions
85
+ allowUnauthenticated : true
51
86
52
87
# NOTE: the following uses an "event" event (pubSub event in this case).
53
88
# Please create the corresponding resources in the Google Cloud
0 commit comments