Unable to set up Export Collections to BigQuery extension. Unable to uninstall: failed to remove IAM roles from Service Account - firebase

I tried installing the Export Collections to BigQuery extension to send firestore collection data to BigQuery. The installation succeeded but could never get the queries to work. I kept getting the error:
Not found: Dataset myproject:firestore_events was not found in location US
I tried uninstalling and reinstalling. I now have two instances of the extension and attempts to uninstall fail with ther error:
failed to remove IAM roles from Service Account for projects/myproject/instances/firestore-bigquery-export
Is there a way to uninstall manually?
Is there a way to install manually?

The following error message means that your FROM statement may not contain the proper query structure - project, database, and table:
Not found: Dataset myproject:firestore_events was not found in location US
For example:
SELECT *
FROM `my-project.my-database.my-table`
Please note the backticks.
Refer to Error: Not found: Dataset my-project-name:domain_public was not found in location US for details about a similar issue.
Now, in regards to the second error message:
failed to remove IAM roles from Service Account for projects/myproject/instances/firestore-bigquery-export
I suspect that after reinstalling and uninstalling one of the extension instances, its service account might already be deleted and thus failing to remove its IAM roles.
The installation of this extension generates a new service account that has the BigQuery Data Editor role to access your project and resources. This role allows the extension to configure and export data into BigQuery.
From documentation:
When you uninstall an extension from your project, Firebase deletes the service account created for that instance of the extension. After this deletion of the service account, the extension cannot run in your project because it no longer has any access rights to your project or data.
I was able to uninstall and reinstall the Export Collections to BigQuery extension to avoid duplicates in my project without any issues.
To answer your last question, I am not aware of any other methods to install/uninstall Firebase extensions other than what is shown in the documentation. You can install the extension using the Firebase Console or the Firebase CLI:
1 - Install the Firebase CLI or update it to the latest version:
npm install -g firebase-tools
2 - Install the extension:
firebase ext:install firestore-bigquery-export --project=projectId_or_alias
Edited
We can take the following steps to troubleshoot error:
failed to remove IAM roles from Service Account for projects
Please make sure that you're the owner of the project that you are installing extensions in.
Refer to this GitHub issue to uninstall the extension using the CLI.
If that didn't help, try disabling and re-enabling the Firebase Extensions API inside the GCP Console.
Please make sure that Firebase Management API is enabled in your project.
If that didn't help, navigate to the IAM Permissions page on the Cloud Console, and find the service account.
Add the Cloud Functions Developer and Firebase Extensions API Service Agent roles.
If those roles not available for some reason, just adding the Project Editor role also works as a catch-all. However, using the catch-all also provides additional permissions to the service accounts.

I had a similar issue when installing a Firebase Extension.
My error was adding an IAM role that did not exist, this not only failed to install the extension, but also then stopped me from uninstalling with the error failed to remove IAM roles from Service Account for.
To fix this issue I edited what I knew was the broken permission to be the correct role and then ran the following...
firebase ext:update ${ext-name} . --project={project-name}.
Alternativley, removing all roles completetly from the configuration and updating will have the same result.
One completed, the uninstallation process will automatically continue and uninstall your extension.

Related

Firebase trouble when initializing CLI to deploy a react app

I keep getting the error below:
? Are you ready to proceed? Yes
? Which Firebase features do you want to set up for this directory? Press Space to select features, then Enter to confirm your choices. Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys
=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.
? Please select an option: Use an existing project
Error: Failed to list Firebase projects. See firebase-debug.log for more info.
PS C:\Users\xxxxxlinked-in>
I have tried everything I can find on StackOverflow:
firebase login will log me in.
I have also done the firebase login --reauth one and also just reinstalling it npm install -g firebase-tools.
Its just when I go to use an existing project.
If it helps to know, I keep gettin another error when uing this command firebase projects:list.

Firestore / Algolia integration fail: API key problem

I am trying to add the Algolia search extension to a Firebase/Firestore project.
I have followed these steps:
https://firebase.google.com/products/extensions/algolia-firestore-algolia-search
Everything works until I try to deploy the extensions in Firebase through the terminal with the command:
firebase deploy --only extensions
This is the error I get:
i extensions: Verifying secret params for firestore-algolia-search
Extensions deploy had errors:
- create firestore-algolia-search
Request had 1 validation errors: `params.ALGOLIA_API_KEY`: param was required but not provided.
Error: Extensions deployment failed validation. No changes have been made to the Extension instances on
When prompted in the terminal, I first entered the (Algolia) Search-Only API Key. I then realised this probably requires the admin API key, so I changed in to the admin API key in my project here:
\extensions\firestore-algolia-search.secret.local
I still get the error above.
My question: 1. which API key should I use (i think in the terminal it was stated that it would be needed by the emulator) and 2. where do I change it?
Thank you for any help!!

Firebase cloud functions init not working

I want to use Firebase cloud functions but when I try to init exists project I get error.
This is the error "Error: HTTP Error: 403, The caller does not have permission"
I created project before and then I moved project folder. When I had tried deploy, it wasn't work. I don't remember which error I got. And then I tried init same project but I got this error.
I tried logout and login again but it wasn't work.
I deleted "firebase-tools" but it wasn't work too.
And after I tried on different computer and I got same error.
And also I have Firebase Admin permission.
The firebase init command initializes/enables the project to use Cloud Functions for Firebase. Owners or Editors should use this command. Owners/Editors have higher permissions which allows APIs to be enabled (e.g. allowing the project to create VMs, Cloud Functions, or create a NoSQL Database).
Therefore I think you should perform this operation with Owner/Editor role.
You need to have Owner or Editor IAM permission on the GCP project to use firebase init command.
The firebase init command initializes/enables the project to use Cloud Functions/Hosting for Firebase. Owners/Editors have higher permissions that allow APIs to be enabled etc.
it is a first-time task when you starting the development, and then init command can be avoided if you have set up your cloud functions code in VCS for multiple developers or you.
i.e, Usually after writing code, you will replicate the project to other developers, who will then also write code and use firebase use yourprojectid further.

Firebase deploy fails after adding second project

After adding a second project to my code using the command $ firebase use --add second-project, I get the error
There was an issue deploying your functions. Verify that your project has a Google App Engine instance setup at https://console.cloud.google.com/appengine and try again. If this issue persists, please contact support.
Error: HTTP Error: 404, Could not find Application "second-project".
when I run $ firebase deploy.
I have added separate targets and a web app through Firebase console for the second project.
What should I be checking to get rid of this error?
I just ran into this same exact issue as well. Leaving this here for anyone that runs into this issue in the future. What caused this error for me was a permissions error, when Firebase tried to access specific resources in Google Cloud such as Cloud Functions without the necessary IAM/service accounts in place.
This happens when you create a new Firebase project without setting the Default GCP resource location under Settings > General in the Firebase Console, which occurs when you create a new Firebase project without doing any additional setup. You can set this in the settings or this is also set when you follow the walk-through instructions for setting up services such as Firestore or Firebase Storage in the Firebase console.
Without this set, the <YOUR_FIREBASE_PROJECT_NAME>#appspot.gserviceaccount.com IAM/service account will not be created in Google Cloud (which is needed to create/access specific resources), therefore when you run firebase deploy, it will fail with the error you mentioned above.
You can also check why your firebase deploy is failing in the firebase-debug.log that is generated when running this command (that's how I found out the cause of this error). Though I think this file is deleted after the command finishes execution, so you'll have to pipe the output into a file or save it some other way.
TL;DR: Set Default GCP resource location, one way this can be done is in the Firebase Console under Settings > General.

"Error: Permission denied" when running firebase init and choosing database

So I’m testing out the CLI today and firebase init with db/hosting selected, and choosing to create a new project, always says Error: Permission denied..
sudo firebase init didn’t help.
firebase-tools version 3.0.3 on OS X 10.11.5.
firebase init
You're about to initialize a Firebase project in this directory:
/Users/splaktar/Git/tmp
Before we get started, keep in mind:
* You are initializing in an existing Firebase project directory
? What Firebase CLI features do you want to setup for this folder? Database: Deploy Firebase Realtime Database Rules
=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.
? What Firebase project do you want to associate as default? [don't setup a default project]
=== Database Setup
Firebase Realtime Database Rules allow you to define how your data should be
structured and when your data can be read from and written to.
? What file should be used for Database Rules? database.rules.json
Error: Permission denied.
I've tried the answers here but they did not help. Is this just a bug in the firebase-tools?
I have the same issue and this is how I fixed it.
run firebase init
Deselect ❯◯ Database: Deploy Firebase Realtime Database Rules
Go through other steps to setup the initial app, selecting the default for each should work just fine.
run firebase serve
Hope that helps.
Sometimes it could happen when .firebaserc file exists.
Remove .firebaserc file and reattempt firebase init.
I was with the same problem, but I was not accessing the right account.
After accessed the right account, I created a new project and run "firebase list" (before this not happened) and my new project was there.
This solved my problem.
You need to have Owner or Editor IAM permission on the GCP project to use firebase init command.
The firebase init command initializes/enables the project to use Cloud Functions/Hosting etc for Firebase. Owners/Editors have higher permissions that allow APIs to be enabled etc.
it is a first-time task when you starting the development, and then init command can be avoided if you have set up your cloud functions code in VCS for multiple developers or you.
i.e, Usually after writing code, you will replicate the project to other developers, who will then also write code and use firebase use yourprojectid further.

Resources