Skip to content

permissions error when deploying multiple functions at the same time with firebase deploy #11576

In review

Description

@pldelattre

[REQUIRED] Environment info

firebase-tools: 15.37.0

Platform: Mac

[REQUIRED] Test case

[REQUIRED] Steps to reproduce

Deploy 9 new instances of firestore-bigquery-export function kit using firebase deploy --only functions

[REQUIRED] Expected behavior

firebase deploy --only functions should deploy all functions without failing

[REQUIRED] Actual behavior

it fails with error :
Error: Cannot enable declarative security because you do not have permissions necessary to create the service account. Please ask an IAM administrator to perform the next deploy.

If i deploy functions individually, I don't have any error and permissions are correctly created.
The error message is extremely misleading

Activity

  1. IzaakGough commented on Nov 23, 2026

    @IzaakGough
    Contributor

    Hi @pldelattre, thanks for raising this!

    I tried to reproduce this on firebase-tools 15.37.0 (macOS) but wasn't able to. Here is what I did:

    1. Installed the kit:

      firebase functions:kits:install --package @firebase-function-kits/[email protected]
    2. Configured 9 new instances of it in firebase.json, each with its own config directory:

      "instances": {
        "repro-1": "function-kits/firestore-bigquery-export/config-repro-1",
        "repro-2": "function-kits/firestore-bigquery-export/config-repro-2",
        ...
        "repro-9": "function-kits/firestore-bigquery-export/config-repro-9"
      }

      Each instance used a different collection, dataset and table, with the Firestore (default) database and functions in us-central1. All other parameters were left at the kit defaults.

    3. Deployed all 9 at once, from an account with the Owner role on the project:

      firebase deploy --only functions

    The CLI created a managed service account for each instance one after another, granted it roles, and then created all 36 functions. The deploy finished without the declarative security error.

    To help me with reproducing this issue would you be able to share the following:

    • The output of firebase deploy --only functions --debug from a failing run (please remove anything sensitive first)
    • The account you deploy with (your user account or a service account) and its IAM roles on the project
    • Your kit configuration: the functions section of firebase.json and the parameter values for one instance (without any secrets)
  2. self-assigned this
    on Nov 23, 2026
  3. cabljac commented on Nov 23, 2026

    @cabljac
    Contributor

    Hi @pldelattre, thanks for the extra detail. We think the message is misleading. The permissions check before the deploy is the same for one instance or nine, so your account is probably fine.

    Each kit instance deploys as its own codebase, and each codebase gets its own managed service account. The CLI creates those accounts one after another without a retry. If creating an account fails for any reason (for example a rate limit or the project's service account quota), the CLI shows the same Cannot enable declarative security because you do not have permissions... error. The cause is in grantNewRoles in src/deploy/functions/release/fabricator.ts.

    To confirm, could you share:

    • The firebase deploy --only functions --debug output from a failing run. The most useful part is the error logged right after Creating managed service account firebase-fn-..., because it contains the real status code and message.

    • The number of service accounts in the project:

      gcloud iam service-accounts list --project YOUR_PROJECT_ID --format="value(email)" | wc -l

    In the meantime, we'll look at changing the CLI to show the real error instead of the permissions message.

  4. pldelattre commented on Nov 23, 2026

    @pldelattre
    Author

    Hi @cabljac @IzaakGough,

    I have redeployed to a brand new gcp project and run firebase deploy --only functions --debug

    I was able to reproduce the error. And we can see a quota error (too many service accounts created per minute) in the logs :

    [2026-11-23T17:21:53.195Z] FirebaseError: Request to https://iam.googleapis.com/v1/projects/PROJECT_NAME_REDACTED/serviceAccounts had HTTP Error: 429, A quota has been reached for project number PROJECT_NUMBER_REDACTED: Service accounts created per minute per project.
        at responseToError (/Users/myuser/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/responseToError.js:53:12)
        at RetryOperation._fn (/Users/myuser/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/apiv2.js:415:77)
        at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
    
    Error: Cannot enable declarative security because you do not have permissions necessary to create the service account. Please ask an IAM administrator to perform the next deploy.
    
  5. IzaakGough commented on Nov 23, 2026

    @IzaakGough
    Contributor

    Hi @pldelattre, thank you for testing this on a new project and sharing the log. That confirms the cause.

    The CLI creates one managed service account per kit instance, one after another and without a retry. On your project one of the creations hit the "Service accounts created per minute per project" quota, and the CLI reported that 429 as a permissions error. I'll look into a change to retry when this quota is hit and to show the real error instead of the permissions message.

    Until then, deploying a few instances at a time and waiting a minute between deploys should avoid the quota.

  6. pldelattre commented on Nov 24, 2026

    @pldelattre
    Author

    Thanks for this quick fix @IzaakGough
    That looks perfect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions