0

I am trying to deploy Cloud Functions for Firebase Node.js, and I am following the documentation here https://firebase.google.com/docs/functions/get-started?gen=2nd#deploy-functions-to-a-production-environment

I wanted to use custom service account with the functions instead of the default App engine one.

I am unable to pass this parameter while deploying firebase deploy --only functions like normal gcloud functions deploy --service-account

I have tried also to override the service account after the function creation by gcloud functions deploy FUNCTION_NAME --service-account "SA@PROJECT_ID.iam.gserviceaccount.com"

I got this error message ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: function.js does not exist; Error ID: 7485c5b6

Omar Merghany
  • 155
  • 1
  • 2
  • 9

1 Answers1

1

The Firebase CLI doesn't support the options documented for gcloud. They are different tools with different interfaces and are not meant to be compatible with each other. To see all the options supported by Firebase, see the reference documentation.

However, the Firebase CLI doesn't let you change anything related to service accounts in use. It only uses the default. See:

If you want to use a different service account at runtime, you will have to initialize any SDK that you're using with those service account credentials, which you will also have to deploy along with the function.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • thanks @doug-stevenson for clarifying, can you elaborate what do you mean by initializing SDK, the main point for me is that I do not want to add the service account as a JSON file in the code for security best practices and wanted to leverage GCP auth mechanism. Finally can I convert Cloud Functions for Firebase to a normal Cloud function, as I do not quite get the difference between them specially they are using similar infra? – Omar Merghany Aug 24 '23 at 19:29
  • 1
    Right, you can't do that with Firebase. You have to bring your own credentials if you don't want to take the default. You don't have to use the Firebase CLI at all if you don't want and instead do everything in gcloud, but then you all all the other conveniences of Firebase. You choose. – Doug Stevenson Aug 24 '23 at 19:34