Google Cloud offers Identity and Access Management (IAM), which lets you give more granular access to specific Google Cloud resources and prevents unwanted access to other resources. This page describes the Firestore in Datastore mode IAM roles. For a detailed description of IAM, read the IAM documentation .
IAM lets you adopt the security principle of least privilege , so you grant only the necessary access to your resources.
IAM lets you control who (users)has what (roles)permission to whichresources by setting IAM policies. IAM policies grant
specific role(s) to a user, giving the user certain
permissions. For example, you can grant the datastore.indexAdmin 
role to a
user and the user can create, modify, delete, list, or view indexes.
Permissions and Roles
This section summarizes the permissions and roles Firestore in Datastore mode supports.
Permissions
The following table lists the permissions that Firestore in Datastore mode supports.
datastore.databases.export 
datastore.databases.bulkDelete 
datastore.databases.get 
Commit with empty mutations.
datastore.databases.import 
datastore.databases.getMetadata 
datastore.databases.list 
datastore.databases.create 
datastore.databases.update 
datastore.databases.delete 
datastore.databases.clone 
If your clone 
request contains a tags 
value, then the following additional permissions are required:
-  datastore.databases.createTagBinding
If you would like to verify whether the tag bindings are set successfully by listing the bindings, then the following additional permissions are required:
-  datastore.databases.listTagBindings
-  datastore.databases.listEffectiveTags
datastore.databases.createTagBinding 
datastore.databases.deleteTagBinding 
datastore.databases.listTagBindings 
datastore.databases.listEffectiveTagBindings 
datastore.entities.allocateIds 
datastore.entities.create 
datastore.entities.delete 
datastore.entities.get 
datastore.entities.list 
(
datastore.entities.get 
is required to access the entity data.)datastore.entities.update 
datastore.indexes.create 
datastore.indexes.delete 
datastore.indexes.get 
datastore.indexes.list 
datastore.indexes.update 
datastore.namespaces.get 
datastore.namespaces.list 
datastore.operations.cancel 
datastore.operations.delete 
datastore.operations.get 
datastore.operations.list 
resourcemanager.projects.get 
resourcemanager.projects.list 
datastore.statistics.get 
datastore.statistics.list 
(
datastore.statistics.get 
is required to access the statistics entity data.)appengine.applications.get 
datastore.locations.get 
datastore.locations.list 
datastore.keyVisualizerScans.get 
datastore.keyVisualizerScans.list 
datastore.backupSchedules.get 
datastore.backupSchedules.list 
datastore.backupSchedules.create 
datastore.backupSchedules.update 
datastore.backupSchedules.delete 
datastore.backups.get 
datastore.backups.list 
datastore.backups.delete 
datastore.backups.restoreDatabase 
datastore.insights.get 
Predefined roles
With IAM, every Datastore API method requires that the account making the API request has the appropriate permissions to use the resource. Permissions are granted by setting policies that grant roles to a user, group, or service account. In addition to the basic roles, Owner, Editor, and Viewer , you can grant Firestore in Datastore mode roles to the users of your project.
The following table lists the Firestore in Datastore mode IAM roles. You can grant multiple roles to a user, group, or service account.
| Role | Permissions | Description | 
|---|---|---|
| roles/datastore.owner | appengine.applications.getdatastore.*resourcemanager.projects.getresourcemanager.projects.list | Full access to the database instance. For Datastore Admin access, grant the appengine.appAdminrole to the principal. | 
| roles/datastore.user | appengine.applications.getdatastore.databases.getdatastore.databases.getMetadatadatastore.databases.listdatastore.entities.*datastore.indexes.listdatastore.namespaces.getdatastore.namespaces.listdatastore.statistics.getdatastore.statistics.listresourcemanager.projects.getresourcemanager.projects.list | Read/write access to data in a Datastore mode database. Intended for application developers and service accounts. | 
| roles/datastore.viewer | appengine.applications.getdatastore.databases.getdatastore.databases.getMetadatadatastore.databases.listdatastore.entities.getdatastore.entities.listdatastore.indexes.getdatastore.indexes.listdatastore.namespaces.getdatastore.namespaces.listdatastore.statistics.getdatastore.statistics.listresourcemanager.projects.getresourcemanager.projects.listdatastore.insights.get | Read access to all Datastore mode database resources. | 
| roles/datastore.importExportAdmin | appengine.applications.getdatastore.databases.exportdatastore.databases.getMetadatadatastore.databases.importdatastore.operations.canceldatastore.operations.getdatastore.operations.listresourcemanager.projects.getresourcemanager.projects.list | Full access to manage imports and exports. | 
| roles/datastore.bulkAdmin | resourcemanager.projects.getresourcemanager.projects.listdatastore.databases.getMetadatadatastore.databases.bulkDeletedatastore.operations.canceldatastore.operations.getdatastore.operations.list | Full access to manage bulk operations. | 
| roles/datastore.indexAdmin | appengine.applications.getdatastore.databases.getMetadatadatastore.indexes.*datastore.operations.getdatastore.operations.listresourcemanager.projects.getresourcemanager.projects.list | Full access to manage index definitions. | 
| roles/datastore.keyVisualizerViewer | datastore.databases.getMetadatadatastore.keyVisualizerScans.getdatastore.keyVisualizerScans.listresourcemanager.projects.getresourcemanager.projects.list | Full access to Key Visualizer scans. | 
| roles/datastore.backupSchedulesViewer | datastore.backupSchedules.getdatastore.backupSchedules.list | Read access to backup schedules in a Datastore mode database. | 
| roles/datastore.backupSchedulesAdmin | datastore.backupSchedules.getdatastore.backupSchedules.listdatastore.backupSchedules.createdatastore.backupSchedules.updatedatastore.backupSchedules.deletedatastore.databases.listdatastore.databases.getMetadata | Full access to backup schedules in a Datastore mode database. | 
| roles/datastore.backupsViewer | datastore.backups.getdatastore.backups.list | Read access to backup information in a Datastore mode location. | 
| roles/datastore.backupsAdmin | datastore.backups.getdatastore.backups.listdatastore.backups.delete | Full access to backups in a Datastore mode location. | 
| roles/datastore.restoreAdmin | datastore.backups.getdatastore.backups.listdatastore.backups.restoreDatabasedatastore.databases.listdatastore.databases.createdatastore.databases.getMetadatadatastore.operations.listdatastore.operations.get | Ability to restore a Datastore mode backup into a new database. This role also gives the ability to create new databases, not necessarily by restoring from a backup. | 
| roles/datastore.cloneAdmin | datastore.databases.clonedatastore.databases.listdatastore.databases.createdatastore.databases.getMetadatadatastore.operations.listdatastore.operations.get | Ability to clone a Datastore mode database into a new database. This role also gives the ability to create new databases, not necessarily by cloning. | 
| roles/datastore.statisticsViewer | resourcemanager.projects.getresourcemanager.projects.listdatastore.databases.getMetadatadatastore.insights.getdatastore.keyVisualizerScans.getdatastore.keyVisualizerScans.listdatastore.statistics.listdatastore.statistics.get | Read access to Insights, Stats, and Key Visualizer scans. | 
Custom roles
If the predefined roles don't address your business requirements, you can define your own custom roles with permissions that you specify:
Required roles to create and manage tags
If any tag is represented in create or restore actions, some roles are required. See Creating and managing tags for more details on creating tag key-value pairs before associate them to the database resources.
The following listed permissions are required.
View tags
-  datastore.databases.listTagBindings
-  datastore.databases.listEffectiveTags
Manage tags on resources
The following permission is required for the database resource you're attaching the tag value.
-  datastore.databases.createTagBinding
Required Permissions for API methods
The following table lists the permissions that the caller must have to call each method:
| Method | Required Permission(s) | 
|---|---|
|  allocateIds 
 | datastore.entities.allocateIds | 
|  beginTransaction 
 | datastore.databases.get | 
|  commit 
with empty mutations | datastore.databases.get | 
|  commit 
for an insert | datastore.entities.create | 
|  commit 
for an upsert | datastore.entities.createdatastore.entities.update | 
|  commit 
for an update | datastore.entities.update | 
|  commit 
for a delete | datastore.entities.delete | 
|  commit 
for a lookup | datastore.entities.getFor a lookup related to metadata or statistics, see Required Permissions for Metadata and Statistics . | 
|  commit 
for a query | datastore.entities.listdatastore.entities.get(if the query is not a keys-only query 
)For a query related to metadata or statistics, see Required Permissions for Metadata and Statistics . | 
|  lookup 
 | datastore.entities.getFor a lookup related to metadata or statistics, see Required Permissions for Metadata and Statistics . | 
|  rollback 
 | datastore.databases.get | 
|  runQuery 
 | datastore.entities.listdatastore.entities.get(if the query is not a keys-only query 
)For a query related to metadata or statistics, see Required Permissions for Metadata and Statistics . | 
|  runQuery 
with a kindless query | datastore.entities.getdatastore.entities.listdatastore.statistics.getdatastore.statistics.list | 
Required Permissions for Metadata and Statistics
The following table lists permissions that the caller must have to call methods on Metadata and Statistics .
| Method | Required Permission(s) | 
|---|---|
|  lookup 
of entities with kind names matching __Stat_*__ | datastore.statistics.get | 
|  runQuery 
using kinds with names matching __Stat_*__ | datastore.statistics.getdatastore.statistics.list | 
|  runQuery 
using the kind __namespace__ | datastore.namespaces.getdatastore.namespaces.list | 
Required roles to create a Datastore mode database instance
To create a new Datastore mode database instance, you require either the Owner role or the Datastore Owner role .
Datastore mode databases requires an active App Engine application.
If the project doesn't have an application, Firestore in Datastore mode creates one
for you. In that case, you require the appengine.applications.create 
permission from the Owner 
role or from an IAM custom role 
containing
the permission.
Role change latency
Firestore in Datastore mode caches IAM permissions for 5 minutes, so it will take up to 5 minutes for a role change to become effective.
Managing IAM
You can get and set IAM policies using the Google Cloud console, the IAM methods, or the Google Cloud CLI.
- For the Google Cloud console, see Access control using the Google Cloud console .
- For the IAM methods, see Access control using the API .
- For the gcloud CLI, see Access control using the gcloud tool .
Configure conditional access permissions
You can use IAM Conditions to define and enforce conditional access control.
For example, the following condition assigns a principal the datastore.user 
role up until a specified date:
  { 
  
 "role" 
 : 
  
 "roles/datastore.user" 
 , 
  
 "members" 
 : 
  
 [ 
  
 "user:travis@example.com" 
  
 ], 
  
 "condition" 
 : 
  
 { 
  
 "title" 
 : 
  
 "Expires_December_1_2023" 
 , 
  
 "description" 
 : 
  
 "Expires on December 1, 2023" 
 , 
  
 "expression" 
 : 
  
 "request.time < timestamp('2023-12-01T00:00:00.000Z')" 
  
 } 
 } 
 
 
To learn how to define IAM Conditions for temporary access, see Configure temporary access .
To learn how to configure IAM Conditions for access to one or more databases, see Configure database access conditions .
What's next
- Learn more about IAM .
- Grant IAM roles .

