Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for GOOGLE_CLOUD_QUOTA_PROJECT across Firebase API client #6801

Closed
jeremydw opened this issue Feb 21, 2024 · 1 comment · Fixed by #6836
Closed

Add support for GOOGLE_CLOUD_QUOTA_PROJECT across Firebase API client #6801

jeremydw opened this issue Feb 21, 2024 · 1 comment · Fixed by #6836

Comments

@jeremydw
Copy link

jeremydw commented Feb 21, 2024

We're running into an issue running firebase-tools deploy in Google Cloud Build, when invoking the command inside a build step owned by one GCP project, deploying to Firebase owned by another GCP project.

Essentially, the Firebase Management API isn't enabled in the project that owns the build runner, but it is enabled in the project that owns the target of the firebase-tools deploy command.

When firebase-tools deploy performs its pre-deploy checks, it uses the quota project of the Google Cloud Build environment, not the project of the target deployment.

Environment info

We are running firebase-tools inside Google Cloud Build (Ubuntu).

Expected behavior

I believe the GOOGLE_CLOUD_QUOTA_PROJECT environment variable needs to be honored by firebase-tools base API client. Under the hood, I believe what this does is it sets the x-goog-user-project on the outgoing requests to various Google APIs, so those requests are associated with the project of my choice (and not necessarily the environment).

Actual behavior

GOOGLE_CLOUD_QUOTA_PROJECT isn't supported, and the project associated with the environment (or its service account) is used for quota/billing to API requests instead of the desired target project.

This results in this error:

npx firebase-tools@latest deploy --debug --project $TARGET_PROJECT
...
[2024-02-21T00:36:31.601Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/$TARGET_PROJECT {"error":{"code":403,"message":"Firebase Management API has not been used in project $SOURCE_PROJECT_NUMBER before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/firebase.googleapis.com/overview?project=$SOURCE_PROJECT_NUMBER then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.","status":"PERMISSION_DENIED","details":[{"@type":"type.googleapis.com/google.rpc.Help","links":[{"description":"Google developers console API activation","url":"https://console.developers.google.com/apis/api/firebase.googleapis.com/overview?project=587340091677"}]},{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"SERVICE_DISABLED","domain":"googleapis.com","metadata":{"consumer":"projects/$SOURCE_PROJECT_NUMBER","service":"firebase.googleapis.com"}}]}}
@google-oss-bot
Copy link
Contributor

This issue does not seem to follow the issue template. Make sure you provide all the required information.

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