Datastore mode databases are now provisioned unlinked from App Engine by default.
If your database is linked to an App Engine, you can unlink your database.
Active App Engine
An active App Engine app means that an app exists in the same project and that this app is not disabled. It does not require that app to have any usage. The linked app and database must exist in the same region.
If you disable your App Engine app, you also disable access to the Datastore mode database linked to that app.
View App Engine link status
You can check the App Engine unlink state using the REST API:
curl --header "Authorization: Bearer $(gcloud auth print-access-token)" \
--header "Content-type: application/json" \
"https://firestore.googleapis.com/v1/projects/PROJECT_ID/databases/(default)"
In the response, look at the value of appEngineIntegrationMode. If the value
is DISABLED, your database is not linked to an App Engine app.
Unlink your database from App Engine
You can unlink your Datastore mode database from the App Engine app to remove the active App Engine requirement. When you unlink your database, you can disable App Engine without affecting access to your database.Unlinking is a permanent operation.
If you unlink your database, you cannot use the Disable Writes feature in the Datastore Admin page. If writes are currently disabled, unlinking your database will enable writes.
Before unlinking your database from App Engine, make sure you enable the Firestore API and update your IAM permissions.
To unlink your database, Go to the Datastore Admin page and click Unlink database from app. It may take up to five minutes for the unlinking operation to take effect.
Migrating Terraform App Engine Resources
If you previously managed Datastore mode databases via the
google_app_engine_application Terraform resource, you can use the
google_firestore_database Terraform resource instead.
For general instructions on managing Datastore mode databases via Terraform, see Automating database creation.
Create a google_firestore_database resource
In your Terraform configuration file, create a new
google_firestore_database resource:
datastore.tf
resource "google_firestore_database" "database" {
project = "project"
name = "(default)"
location_id = "location"
type = "DATASTORE_MODE"
app_engine_integration_mode = "DISABLED"
// Optional, but recommended for safety
delete_protection_state = "DELETE_PROTECTION_ENABLED"
}
See Datastore locations for the list of available locations. Choose the location corresponding to that of your existing database.
Import the existing Datastore mode database
First, ensure that the Firestore API is enabled.
Next, import the existing Datastore mode database into your Terraform state:
terraform import google_firestore_database.database "(default)"
Next, run: