A Firebase Realtime Database instance.
To get more information about Instance, see:
resource "google_firebase_database_instance" "basic" {
provider = google-beta
project = "my-project-name"
region = "us-central1"
instance_id = "active-db"
}
resource "google_firebase_database_instance" "full" {
provider = google-beta
project = "my-project-name"
region = "europe-west1"
instance_id = "disabled-db"
type = "USER_DATABASE"
desired_state = "DISABLED"
}
resource "google_project" "default" {
provider = google-beta
project_id = "rtdb-project"
name = "rtdb-project"
org_id = "123456789"
labels = {
"firebase" = "enabled"
}
}
resource "google_firebase_project" "default" {
provider = google-beta
project = google_project.default.project_id
}
resource "google_project_service" "firebase_database" {
provider = google-beta
project = google_firebase_project.default.project
service = "firebasedatabase.googleapis.com"
}
resource "google_firebase_database_instance" "default" {
provider = google-beta
project = google_firebase_project.default.project
region = "us-central1"
instance_id = "rtdb-project-default-rtdb"
type = "DEFAULT_DATABASE"
depends_on = [google_project_service.firebase_database]
}
The following arguments are supported:
region
-
(Required)
A reference to the region where the Firebase Realtime database resides.
Check all available regions
instance_id
-
(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 USER_DATABASE
.
Possible values are: DEFAULT_DATABASE
, USER_DATABASE
.
project
- (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
desired_state
- (Optional) The intended database state.
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/{{instance_id}}
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.
database_url
-
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
This resource provides the following Timeouts configuration options:
create
- Default is 20 minutes.update
- Default is 20 minutes.delete
- Default is 20 minutes.Instance can be imported using any of these accepted formats:
projects/{{project}}/locations/{{region}}/instances/{{instance_id}}
{{project}}/{{region}}/{{instance_id}}
{{region}}/{{instance_id}}
{{instance_id}}
In Terraform v1.5.0 and later, use an import
block to import Instance using one of the formats above. For example:
import {
id = "projects/{{project}}/locations/{{region}}/instances/{{instance_id}}"
to = google_firebase_database_instance.default
}
When using the terraform import
command, Instance can be imported using one of the formats above. For example:
$ 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}}
This resource supports User Project Overrides.