3

I am building an automation process for my app, which includes creating several new Firebase projects. (After a lot of investigation, I am sure that several projects are needed, and that it cannot be done with just one project).

I am looking for a way to create a new Firebase project from scratch, and enable Phone Auth, Cloud Firestore, and Cloud Storage, along with security rules, programmatically.

I have taken a look at the Firebase Management REST API, which indeed shows a way to create a new Firebase project and link it to an existing GCP project, but couldn't find a way to configure the project itself through the API (Authentication, Firestore, Storage, etc.).

Is there any way to create and configure a Firebase project from scratch, using an API/SDK or CI/CD of some kind?

Thank you!

F.SO7
  • 695
  • 1
  • 13
  • 37

2 Answers2

1

Have you looked into the firebase-admin SDK? It is a backend-only API because it needs your private key to authenticate against and can therefore not be used in the app directly (shipping your private key with the app would be pretty big security issue!), but as I understand it, creating new firebase-projects is something of a backend activity for you anyway?!

Look at https://firebase.google.com/docs/auth/admin/ for the API's documentation and what you can do with it.

Frank
  • 884
  • 2
  • 10
  • Unfortunately, you cannot create a Firebase project through the Firebase Admin SDK – F.SO7 Aug 08 '22 at 08:26
  • I understood that CREATING your projects wasn’t the problem, but configuring the various aspects of it. And my understanding was also, that this is, what the firebase-admin API is for. But maybe I am wrong… – Frank Aug 08 '22 at 12:24
0

So after a long research, it seems that we can combine the Firebase CLI and the Firebase Admin SDK in order to achieve it.

We can create a new project using the command

firebase projects:create NEW_PROJECT_ID

And then to configure all of the necessary configurations through the admin SDK

F.SO7
  • 695
  • 1
  • 13
  • 37
  • I guess my answer wasn‘t wrong after all… – Frank Aug 14 '22 at 07:17
  • So you can use CLI to create the projects...but how did you programmatically create apps within each project? The REST management API allows you to do that, but it requires a unique service account per project and access token as far as I understand, so not sure how to generate the service account/access token programmatically after the project is created, to then be able to add apps to it. Thanks for any help. – codeman Sep 28 '22 at 13:37