I'm trying to structure my GCP gcloud functions (in python) as a separate file per function. It sounds like from the documentation it should be supported but when I try to use --source as a file name instead of a directory it fails. Is there something I'm doing wrong?
Here is the command I use:
gcloud functions deploy createAccount --runtime python38 --trigger-http --source=postgres/createAccount.py --region us-central1
and the error I get back is:
ERROR: (gcloud.functions.deploy) argument
--source
: Provided path does not point to a directory
But if I put my "createAccount" python function in main.py
inside the postgres directory and use this command the function deploys perfectly:
gcloud functions deploy createAccount --runtime python38 --trigger-http --source=postgres --region us-central1
Here it loojs as though it should accept file names in the --source
option:
https://cloud.google.com/functions/docs/first-python
See this section:
Any ideas if there is a way to not make main.py one big monolith of all my cloud functions?
If we look at the documentation of the gcloud command for deploying functions and the --source
flag within:
https://cloud.google.com/sdk/gcloud/reference/functions/deploy#--source
We find that it unambiguously says that it wants a directory as a parameter and not a source file. The link you gave which seems to say that we can specify a file looks to be in error. I think that is a mistake and it can only be a directory that is supplied with --source
.
This would seem to imply that you can create multiple directories ... where each directory contains just the function you wish to deploy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With