Reputation: 2911
Is there a parameter to add in serverless.yml
to deploy GCP functions (Go
) the same way it can be done by adding --allow-unauthenticated
to gcloud deploy
command?
Can't find any information about this in the serverless documentation.
Upvotes: 1
Views: 560
Reputation: 21
I was able to achieve this by using hooks. You need to add custom > scripts to serverless.yml
(Note: This should work, given that the service account that you are using have the proper access)
like this:
custom:
scripts:
commands:
make-public-function: gcloud functions add-iam-policy-binding ${self:service}-${self:provider.stage}-${opt:opt.function, "functionName"} --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 --stage ${self:provider.stage}
Upvotes: 2
Reputation: 75735
I guess it's not possible. Serverless product uses the Cloud Functions API to deploy te Cloud Functions. To set the allow-unauthenticated, you need to use the IAM API to add the cloudfunctions.invoker
role to allUsers
.
gcloud CLI offers a convenient way to package the both API call in a single command line, but external tool need to implement the same extra effort to achieve that. That's why, I'm pretty sure that is not possible.
Upvotes: 3