Skip to content
Advertisement

Cannot add private python dependency to cloud function

I am trying to deploy a python cloud function on GCP, using a python package pushed on the artifact registry of another project.

I followed the instructions off the google cloud documentation:

The service account that deploys the cloudbuild has the role: Artifact Registry Reader

The error in cloudbuild:

JavaScript

the requirements.txt

JavaScript

the setup.py of the package

JavaScript

the cloudbuild.yaml that deploys the function.

JavaScript

I tried to run the pip install -r requirements.txt and it works locally If I remove the library import, the cloud function deploys and works. I also tried to switch to the –gen2 version of cloud functions, but without luck.

People seem to have similar issues: here with a different error.

Advertisement

Answer

I got the answer to this problem in another question, thanks @Edo Akse:

To grant access to the private library hosted on an artifact registry, you need to give the role Artifact Registry Reader to:

  • The service account running the cloudbuild
  • The default service account of the cloud build (in cate you ran the cloudbuild with a service account you specified yourself). This service account had the name: <PROJECT-NUMBER>@cloudbuild.gserviceaccount.com

You can find the <PROJECT-NUMBER> in the project settings.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement