-
Notifications
You must be signed in to change notification settings - Fork 127
How to deploy public function on GCF? #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@Micka33 it is caused by the location field not supported anymore, please update to latest version and try again |
I don't understand what you mean by
|
Up |
Have the same issue, after updated serverless and serverless-google-cloudfunctions have an error:
|
Does anyone know a way to setup |
Same here, only happens if you upgrade to version |
It would be nice to have a fix for this. Downgrading to 2.4.3 does not work anymore as Google ended support for the previous API, so we are stuck with 3.0.0. So what is the correct way to make a function publicly accessible with serverless? |
I am using private cloud functions with Serverless v3. |
The issue is not able We should be able to configure IAM policy via serverless.yml; similar to AWS. |
Up. |
+1 |
Also having this problem now after upgrading to google provider 3 here - any fix in the pipeline? editMy fix is the following for allowing public access to my cloud function: Create a {
"bindings": [
{
"role": "roles/cloudfunctions.invoker",
"members": [
"allUsers"
]
}
]
} Ensure that you have the
Replacing |
Docs and commands to change this policy using
The previous command needs to be run once per function. New deployments work after making functions public with this command. Apparently, an equivalent to the |
This was very helpful @frandiox Here is what worked for me:
|
When will this be available from the npm package? I see the latest version (3.1.0) was deployed 2 months ago |
The changes made in the above linked PR appear to not fully work (see #222). I'm working through a solution for it, but it does seem like more work needs to be done to get the feature stable enough for a new release. I'll post an update once I make some progress. |
I've opened a PR for an alternative approach for IAM that I've tested locally and seems to work. See: #223 |
Wanted to add my two-pence based on suggestions of @frandiox @kevboutin, I managed to set it up using sls hooks using this plugin: https://www.npmjs.com/package/serverless-plugin-scripts, works pretty nice for me (I have just one function at this point) but I can imagine it might not work in all cases. Here is the snippet: service: YOUR-SERVICE-NAME
custom:
...
# this comes from https://www.npmjs.com/package/serverless-plugin-scripts
scripts:
commands:
make-public: gcloud functions add-iam-policy-binding ${self:service}-${self:provider.stage}-${opt:function, "YOUR-DEFAULT-FUNCTION-NAME"} --member="allUsers" --role="roles/cloudfunctions.invoker" --project=${self:provider.project} --region=${self:provider.region} | xargs echo
hooks:
'after:deploy:deploy': npx sls make-public --function=YOUR-FUNCTION-NAME
... And then it automatically makes the specified functions public after deploy and otherwise I can run Cheers, maybe that helps. |
Shout out to this post for pointing out this workaround: serverless/serverless-google-cloudfunctions#205 (comment) One this is natively supported in the serverless-google-cloudfunctions plugin, the serverless.yml file should be updated accordingly.
Shout out to this post for pointing out this workaround: serverless/serverless-google-cloudfunctions#205 (comment) One this is natively supported in the serverless-google-cloudfunctions plugin, the serverless.yml file should be updated accordingly.
Shout out to this post for pointing out this workaround: serverless/serverless-google-cloudfunctions#205 (comment) One this is natively supported in the serverless-google-cloudfunctions plugin, the serverless.yml file should be updated accordingly.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Thanks @frandiox @kevboutin @deemetree-at-satelligence for the suggestions! I put together a little script that combines the above by running through all the functions defined in The script looks for a parameter #!/bin/bash # Get a list of functions in the serverless.yml file and format as args functions=$(sls print --path functions --transform keys --format text | xargs) # Sort functions as public and private pub=() prv=() for fn in ${functions[@]}; do # if the `allowUnauthenticated: true` flag is defined for the function flag it to be made public if [[ "$(sls print --path functions."$fn" --format yaml | xargs)" == *"allowUnauthenticated: true"* ]]; then pub+=($fn) else prv+=($fn) fi done # Run the mkfunc-pub command for each public function for fn in ${pub[@]}; do echo "Making function \""$fn"\" public..." npx sls mkfunc-pub --function="$fn" done # Run the mkfunc-pvt command for each private function for fn in ${prv[@]}; do echo "Making function \""$fn"\" private..." npx sls mkfunc-pvt --function="$fn" done I've also put together a Serverless Google Functions Starter Project for Golang that includes all this. Hopefully it helps someone! |
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.
@deemetree-at-satelligence Great workaround! For anyone trying this with a service account, make sure that your service account has the 'Security Admin' Role set, otherwise you'll get a 403 error on the scripted IAM policy update command. |
I can't find the answer anywhere in the documentation. Feel free to point it to me.
$> serverless
Since the last

serverless upgrade
, my functions are deployed without the "Cloud function invoker" role set to "allUsers".By the way, I can't find anywhere in the documentation how to set it in
serverless.yml
.Can you help me?
N.B.: Of course, I did set it in the Google Cloud Console UI and the function works perfectly. But then, I can no longer do
serverless deploy
. It displays the following error:The text was updated successfully, but these errors were encountered: