skip to Main Content

I downloaded ServiceAccountKey.json to make local cloud functions env.
I think ServiceAccountKey.json should not be public and it should not be in GCP.
So when I deploy cloud functions, how do I exclude it?
Or is that no problem to upload ServiceAccountKey.json using firebase deploy --only functions?
Please teach me how to do. Thank you.

2

Answers


  1. I would move the ServiceAccountKey.json file out of the deployment folder. This way, it will never be deployed and you also don’t have to add it to the git ignore file. You could also add it to the ignored files in your firebase.json file like so:

    {
        "functions": {
        "source": "functions",
        "ignore": [
            "ServiceAccountKey.json"
        ]
      }
    }
    
    Login or Signup to reply.
  2. If you use Firebase Function emulator, you wouldn’t need to manage service account locally yourself by using Application Default Credentials. You can initialize Admin SDK like this:

    import { initializeApp } from "firebase-admin/app"
    
    const admin = initializeApp(); // <-- no params
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search