Repository navigation
Closed
Labels
Description
[REQUIRED] Environment details
- OS: macOS
- Node.js version: v20.15.1
firebase-toolsversion: 13.11.3
[REQUIRED] Test case
When attempting to deploy Cloud Functions to a staging project in a multi-project setup, the Firebase CLI fails with the following error:
Error: We failed to modify the IAM policy for the project. The functions deployment requires specific roles to be granted to service agents, otherwise the deployment will fail.
i functions: You can either re-run this command as a project owner or manually run the following set of gcloud commands:
i functions: gcloud projects add-iam-policy-binding engage-flow-staging --member=serviceAccount: --role=roles/monitoring.metricWriter
i functions: gcloud projects add-iam-policy-binding engage-flow-staging --member=serviceAccount: --role=roles/cloudtrace.agent
i functions: gcloud projects add-iam-policy-binding engage-flow-staging --member=serviceAccount: --role=roles/logging.logWriter
This error occurs because the Firebase CLI is unable to correctly identify the service account required for deployment, and is instead attempting to modify the IAM policy with an invalid, empty service account.
[REQUIRED] Steps to reproduce
- Create a multi-project setup with a
defaultanddevalias in.firebaserc. - Attempt to deploy Cloud Functions to the
devproject usingfirebase deploy --only functions --project dev.
[REQUIRED] Expected behavior
The Firebase CLI should correctly identify the service account and deploy the functions successfully.
[REQUIRED] Actual behavior
The Firebase CLI fails with an "Invalid service account" error.
Troubleshooting Steps Taken
- Enabled all necessary APIs: We have enabled the
compute.googleapis.com,cloudfunctions.googleapis.com,cloudbuild.googleapis.com,artifactregistry.googleapis.com,cloudscheduler.googleapis.com,run.googleapis.com,eventarc.googleapis.com,pubsub.googleapis.com,storage.googleapis.com, andsecretmanager.googleapis.comAPIs. - Manually granted all required IAM roles: We have manually granted the
roles/monitoring.metricWriter,roles/cloudtrace.agent, androles/logging.logWriterroles to the[email protected]andservice-315566886877@serverless-robot-prod.iam.gserviceaccount.comservice accounts. - Updated
firebase-tools: We have updatedfirebase-toolsto the latest version. - Corrected the
.firebasercfile: We have corrected the.firebasercfile to properly distinguish between thedefaultanddevprojects. - Attempted to force the use of a specific service account: We have attempted to force the use of a specific service account by setting the
GOOGLE_APPLICATION_CREDENTIALSenvironment variable.
Despite these efforts, the deployment continues to fail with the same error. This strongly suggests a bug in the Firebase CLI itself.
Reacted by Sasha Denisov, milinaudara, Linaks and PickleDev
Activity
DenisovAV commentedon Jun 14, 2025
I am experiencing the same issue. When I try to deploy a new function after enabling GenKit Monitoring, it fails. However, deploying only the old functions works correctly.
DenisovAV commentedon Jun 14, 2025
as workaround I downgraded firebase cli to 13.10.2, it works
EyvindEmilio commentedon Jun 14, 2025
Had the same issue. Thanks @DenisovAV. The workaround worked for me, downgrading to [email protected] and Node 20. (I had [email protected])
Linaks commentedon Jun 17, 2025
Same issue here. Downgraded to fix the issue.
taeold commentedon Jun 18, 2025
This should be fixed in the next release per #8760
Thank you!