GCP Firestore (Datastore mode)

Detailed information on the GCP Firestore state store component

Component format

To setup GCP Firestore state store create a component of type state.gcp.firestore. See this guide on how to create and apply a state store configuration.

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. spec:
  6. type: state.gcp.firestore
  7. version: v1
  8. metadata:
  9. - name: project_id
  10. value: <REPLACE-WITH-PROJECT-ID> # Required.
  11. - name: endpoint # Optional.
  12. value: "http://localhost:8432"
  13. - name: private_key_id
  14. value: <REPLACE-WITH-PRIVATE-KEY-ID> # Optional.
  15. - name: private_key
  16. value: <REPLACE-WITH-PRIVATE-KEY> # Optional, but Required if `private_key_id` is specified.
  17. - name: client_email
  18. value: <REPLACE-WITH-CLIENT-EMAIL> # Optional, but Required if `private_key_id` is specified.
  19. - name: client_id
  20. value: <REPLACE-WITH-CLIENT-ID> # Optional, but Required if `private_key_id` is specified.
  21. - name: auth_uri
  22. value: <REPLACE-WITH-AUTH-URI> # Optional.
  23. - name: token_uri
  24. value: <REPLACE-WITH-TOKEN-URI> # Optional.
  25. - name: auth_provider_x509_cert_url
  26. value: <REPLACE-WITH-AUTH-X509-CERT-URL> # Optional.
  27. - name: client_x509_cert_url
  28. value: <REPLACE-WITH-CLIENT-x509-CERT-URL> # Optional.
  29. - name: entity_kind
  30. value: <REPLACE-WITH-ENTITY-KIND> # Optional. default: "DaprState"
  31. - name: noindex
  32. value: <REPLACE-WITH-BOOLEAN> # Optional. default: "false"
  33. - name: type
  34. value: <REPLACE-WITH-CREDENTIALS-TYPE> # Deprecated.

Warning

The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described here.

Spec metadata fields

FieldRequiredDetailsExample
project_idYThe ID of the GCP project to use“project-id”
endpointNGCP endpoint for the component to use. Only used for local development with (for example) GCP Datastore Emulator. The endpoint is unnecessary when running against the GCP production API.“localhost:8432”
private_key_idNThe ID of the prvate key to use“private-key-id”
privateKeyNIf using explicit credentials, this field should contain the private_key field from the service account json——-BEGIN PRIVATE KEY——-MIIBVgIBADANBgkqhkiG9w0B
client_emailNThe email address for the client“eample@example.com”
client_idNThe client id value to use for authentication“client-id”
auth_uriNThe authentication URI to usehttps://accounts.google.com/o/oauth2/auth
token_uriNThe token URI to query for Auth tokenhttps://oauth2.googleapis.com/token
auth_provider_x509_cert_urlNThe auth provider certificate URLhttps://www.googleapis.com/oauth2/v1/certs
client_x509_cert_urlNThe client certificate URLhttps://www.googleapis.com/robot/v1/metadata/x509/x
entity_kindNThe entity name in Filestore. Defaults to “DaprState”“DaprState”
noindexNWhether to disable indexing of state entities. Use this setting if you encounter Firestore index size limitations. Defaults to “false”“true”
typeNDEPRECATED The credentials type“serviceaccount”

GCP Credentials

Since the GCP Firestore component uses the GCP Go Client Libraries, by default it authenticates using Application Default Credentials. This is explained in the Authenticate to GCP Cloud services using client libraries guide.

Setup GCP Firestore

You can use the GCP Datastore emulator to run locally using the instructions here.

You can then interact with the server using http://localhost:8432.

Follow the instructions here to get started with setting up Firestore in Google Cloud.

Last modified June 19, 2023: Merge pull request #3565 from dapr/aacrawfi/skip-secrets-close (b1763bf)