Access your database

This page describes how to access a Firestore in Datastore mode database from different platforms.

Before you begin

This document assumes that you've already created a Datastore mode database. If you haven't created a database, follow the instructions in the Firestore in Datastore mode Quickstart.

Access your database from App Engine

To get started with Datastore mode and App Engine, see one of the following language-specific pages:

App Engine Standard Environment App Engine Flexible Environment

Datastore mode permissions for App Engine

App Engine apps can access a Datastore mode database in the same project by default. Each App Engine app uses an App Engine default service account to manage access to Google Cloud services such as Firestore. By default, the App Engine default service account has the Project Editor IAM role, which includes full read and write access to Datastore mode.

You can modify the IAM permissions of your App Engine default service account, but your app might lose access to Firestore unless you assign an IAM role with the required Firestore permissions. The Datastore Owner and Datastore User IAM roles, for example, grant read and write access to Firestore in Datastore mode.

If you disable or delete your App Engine default service account, your App Engine app will lose access to your Datastore mode database. If you disabled your App Engine service account, you can re-enable it, see enabling a service account. If you deleted your App Engine service account within the last 30 days, you can restore your service account, see undeleting a service account.

Access your database from a Compute Engine instance

This section shows how to activate and access a Datastore mode database from a Compute Engine VM instance in a new or existing project.

Datastore mode permissions for Compute Engine

Compute Engine apps can access a Datastore mode database in the same project by default. Each Compute Engine app uses an Compute Engine default service account to manage access to Google Cloud services such as Firestore. By default, the Compute Engine default service account has the Project Editor IAM role, which includes full read and write access to Datastore mode.

To access your database from a Compute Engine instance, complete the following steps:

  1. Enable the Google Compute Engine API for your project.
    Enable the Compute Engine API
  2. Verify that billing is enabled for your Google Cloud project.

  3. Create a Compute Engine instance.

Console

  1. In the Google Cloud console, go to the VM Instances page.
  2. Click the Create instance button.
  3. In the Identity and API access section, set Access scopes to provide access for Datastore. Either click Allow full access to all Cloud APIs to grant access to all Google Cloud APIs, or click Set access for each API, click the dropdown for Datastore, and then click Enabled to grant access to Datastore.
  4. Click the Create button to create the VM instance.
  5. Confirm that your instance is running.
  6. To use this new Compute Engine VM instance, connect to it using your browser.

gcloud

  1. If you haven't already done this, install the Google Cloud CLI and set up