GCP Cloud Functions helpers

198 views Asked by At

Assume we're deploying GCP Cloud Functions from a GitHub repo (mirrored via GCP Source Repositories). Is it possible to set up shared code that can be accessed by both functions below? (e.g. via helpers.py).

helpers.py
function_one/
├── main.py
function_two/
├── main.py
2

There are 2 answers

0
niyi On

Not exactly, since each function is a separate entity. But you could move your helpers.py to its own repository, then import the repository within each individual function.

0
Fabio On

Normally you make a library out of your helpers (like any other libs in your requirements), then you import it as a dependency of function1 or function2.

Cloud Functions will get all your functions dependencies before running the function1.