Skip to content

googleFirebaseDatabaseInstance

A Firebase Realtime Database instance.

\~> Warning: This resource is in beta, and should be used with the terraform-provider-google-beta provider. See Provider Versions for more details on beta resources.

To get more information about Instance, see:

Example Usage - Firebase Database Instance Basic

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.firebaseDatabaseInstance.FirebaseDatabaseInstance(this, "basic", {
  instance_id: "active-db",
  project: "my-project-name",
  provider: "${google-beta}",
  region: "us-central1",
});

Example Usage - Firebase Database Instance Full

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.firebaseDatabaseInstance.FirebaseDatabaseInstance(this, "full", {
  desired_state: "DISABLED",
  instance_id: "disabled-db",
  project: "my-project-name",
  provider: "${google-beta}",
  region: "europe-west1",
  type: "USER_DATABASE",
});

Example Usage - Firebase Database Instance Default Database

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleProjectDefault = new google.project.Project(this, "default", {
  labels: [
    {
      firebase: "enabled",
    },
  ],
  name: "rtdb-project",
  org_id: "123456789",
  project_id: "rtdb-project",
  provider: "${google-beta}",
});
const googleFirebaseProjectDefault = new google.firebaseProject.FirebaseProject(
  this,
  "default_1",
  {
    project: googleProjectDefault.projectId,
    provider: "${google-beta}",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleFirebaseProjectDefault.overrideLogicalId("default");
const googleProjectServiceFirebaseDatabase =
  new google.projectService.ProjectService(this, "firebase_database", {
    project: googleFirebaseProjectDefault.project,
    provider: "${google-beta}",
    service: "firebasedatabase.googleapis.com",
  });
const googleFirebaseDatabaseInstanceDefault =
  new google.firebaseDatabaseInstance.FirebaseDatabaseInstance(
    this,
    "default_3",
    {
      depends_on: [`\${${googleProjectServiceFirebaseDatabase.fqn}}`],
      instance_id: "rtdb-project-default-rtdb",
      project: googleFirebaseProjectDefault.project,
      provider: "${google-beta}",
      region: "us-central1",
      type: "DEFAULT_DATABASE",
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleFirebaseDatabaseInstanceDefault.overrideLogicalId("default");

Argument Reference

The following arguments are supported:

  • region - (Required) A reference to the region where the Firebase Realtime database resides. Check all available regions

  • instanceId - (Required) The globally unique identifier of the Firebase Realtime Database instance. Instance IDs cannot be reused after deletion.


  • type - (Optional) The database type. Each project can create one default Firebase Realtime Database, which cannot be deleted once created. Creating user Databases is only available for projects on the Blaze plan. Projects can be upgraded using the Cloud Billing API https://cloud.google.com/billing/reference/rest/v1/projects/updateBillingInfo. Default value is userDatabase. Possible values are defaultDatabase and userDatabase.

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

  • desiredState - (Optional) The intended database state.

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • id - an identifier for the resource with format projects/{{project}}/locations/{{region}}/instances/{{instanceId}}

  • name - The fully-qualified resource name of the Firebase Realtime Database, in the format: projects/PROJECT_NUMBER/locations/REGION_IDENTIFIER/instances/INSTANCE_ID PROJECT_NUMBER: The Firebase project's projectNumber Learn more about using project identifiers in Google's AIP 2510 standard.

  • databaseUrl - The database URL in the form of https://{instance-id}.firebaseio.com for us-central1 instances or https://{instance-id}.{region}.firebasedatabase.app in other regions.

  • state - The current database state. Set desired_state to :DISABLED to disable the database and :ACTIVE to reenable the database

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 20 minutes.
  • update - Default is 20 minutes.
  • delete - Default is 20 minutes.

Import

Instance can be imported using any of these accepted formats:

$ terraform import google_firebase_database_instance.default projects/{{project}}/locations/{{region}}/instances/{{instance_id}}
$ terraform import google_firebase_database_instance.default {{project}}/{{region}}/{{instance_id}}
$ terraform import google_firebase_database_instance.default {{region}}/{{instance_id}}
$ terraform import google_firebase_database_instance.default {{instance_id}}

User Project Overrides

This resource supports User Project Overrides.