Reputation: 51
is it possible to automate GCP Firestore creation using Terraform or another tool? I cannot find anything about it in docs. Regards
Upvotes: 5
Views: 7738
Reputation: 15018
As of v4.56.0, there is now a google_firestore_database
resource available in the Terraform Google Provider. You can create a new firestore database like this:
resource "google_firestore_database" "database" {
project = google_project.my_project.project_id
name = "(default)"
location_id = "location"
type = "FIRESTORE_NATIVE"
depends_on = [google_project_service.firestore]
}
Upvotes: 1
Reputation: 141
Set the database_type to CLOUD_FIRESTORE or CLOUD_DATASTORE_COMPATIBILITY.
provider "google" {
credentials = file("credentials-file")
}
resource "google_project" "my_project" {
name = "My Project"
project_id = "project-id"
}
resource "google_app_engine_application" "app" {
project = google_project.my_project.project_id
location_id = "location"
database_type = "CLOUD_FIRESTORE"
}
Upvotes: 7
Reputation: 2140
Update 7/23/20: see automating database creation.
You can enable Firestore using the google_project_service resource:
resource "google_project_service" "firestore" {
project = var.project_id
service = "firestore.googleapis.com"
disable_dependent_services = true
}
Edit: I don't see any possibility to create the database itself, however, you can use the google_firebase_project_location to set the location of the Firestore (this will also set the GAE location and the location of the default bucket).
Upvotes: 1