skip to Main Content

I used to be able to deploy Cloud Functions for Firebase with a service account with this:

gcloud functions deploy MyFunction --service-account [email protected]

That now throws an error that it can’t find lib/index.js. I’ve tried different paths in main: in package.json but nothing works. Any suggestions for fixing that error?

And is there a way to deploy Firebase Cloud Functions with an IAM service account? This doesn’t work:

firebase deploy --only functions:MyFunction --service-account [email protected]

2

Answers


  1. Chosen as BEST ANSWER

    I figured it out. The emulator requires a path to the service account key this way:

    const options = {
      keyFilename: ".../.../environments/service_account_keys/my-project-12345.json",
    };
    import { TranslationServiceClient } from '@google-cloud/translate';
    const translationClient = new TranslationServiceClient(options);
    

    The cloud requires a path to the service account key this way:

    import { TranslationServiceClient } from '@google-cloud/translate';
    const translationClient = new TranslationServiceClient();
    export const GOOGLE_APPLICATION_CREDENTIALS = ".../.../environments/service_account_keys/my-project-12345.json";
    

    I'll write a detailed answer tomorrow morning.


  2. The Firebase CLI does not support this. You can think of the Firebase CLI as a simplified view of GCP services, and this is not part of the simplified view it exposes.

    If you want to see a list of everything the CLI can do, find its reference documentation. You can also use --help on the command line to get help on any command to see what your choices are.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search