1

I am looking into automating the deployment of a project that is made up of multiple functions that are triggers on multiple realtime database instances.

Using firebase deploy allows you to deploy both functions and database rules. I have also created targets so i can deploy different rules for different database instances.

The only missing part of my automation is actually creating those different database instances via the Firebase CLI tool; Since deploying a trigger function to a specific database that doesn't exist will fail. Ideally i would like to make sure to create those database instances if they don't exist and then continue my deployment.

Is there a way to create different database instances via the CLI ?

5
  • 2
    I don't believe there's a way to do this, but you can always file a feature request: firebase.google.com/support/contact/bugs-features Commented Oct 2, 2018 at 2:38
  • > I have also created targets so i can deploy different rules for different database instances. That sounds suspicious. The most common (and idiomatic) use-case for having multiple databases is for sharding users over database instances. In such a case, each database instance would have the same rules. It sounds a bit like a XY problem: what are you trying to accomplish by automatically creating database instances? Commented Oct 2, 2018 at 2:58
  • @DougStevenson That sounds like an answer. :-) Commented Oct 2, 2018 at 2:58
  • @FrankvanPuffelen I am using different instances of the database for different flavours of the same projects thats, in some unique case the database rule differs a bit and thats why im using different targets... that is actually working pretty well and not my problem, that was just to give context. What i want to accomplish is to actually be able to add this to my CD build script to create a new database instance if a new flavour is needed. Commented Oct 2, 2018 at 3:48
  • 2
    I'd recommend using separate projects for that. As Doug commented: there is currently no API for creating database instances. Commented Oct 2, 2018 at 3:56

2 Answers 2

1

I don't know when it was added, but this might be useful for others having the same question.

You can create a Firebase Realtime Database instance using the following CLI command:

firebase database:instances:create [instance-name]

I don't know why this isn't described in the CLI reference, but it is mentioned here: https://firebaseopensource.com/projects/firebase/firebase-tools/

Sign up to request clarification or add additional context in comments.

Comments

0

You can Create realtime database instance by firebase CLI using the below command

firebase database:instances:create -P <alias_or_project_id> <DBinstanceName>

This Command work fine if you have paid plan.

For Free Plan it throw error:- FirebaseError: HTTP Error: 400, Precondition check failed.

Note : <DBinstanceName> should be alpha-numeric with hyphens.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.