10

I'm trying to create a schedule Cloud Function exporting my Firestore database to create backups. The code is running fine when serving on my local machine (which uses my personal user account with owner role) but failes once deployed. I already found out that I need to add the 'Storage Admin' and 'Datastore Import Export Admin' to the service account used when running the cloud function, but I can't figure out which service account is used for the functions.

Does anyone know which service account is used?

crysxd
  • 3,013
  • 16
  • 31

1 Answers1

23

Firebase Cloud Functions use the {project-id}@appspot.gserviceaccount.com service account (App Engine default service account). Roles and permissions added to this service account carry over to the Cloud Functions runtime.

Good to know: When using Google Cloud Functions, the service account being used while running the function can be defined when deploying the function.

crysxd
  • 3,013
  • 16
  • 31
  • 15
    You can't specify the service account to use when deploying with the Firebase CLI. That only works when you deploy with gcloud, and you can't use gcloud to deploy functions that use the Firebase SDK to build functions. If you need a different service account for functions deployed with the Firebase CLI, you need to deploy the credentials for that account, and use them manually. – Doug Stevenson Jun 16 '19 at 16:16
  • Oh my god you are a life saver. – dshukertjr Dec 11 '19 at 05:40
  • 2
    what do you mean deploy them and use them manually? I can't deploy my functions because the service account is gone. – Gabe O'Leary Feb 20 '20 at 02:59
  • Then you have an other issue to solve...I mean by manually running them locally on your machine and deploy them to Google. – crysxd Feb 20 '20 at 11:19