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: type
  10. value: <REPLACE-WITH-CREDENTIALS-TYPE> # Required. Example: "serviceaccount"
  11. - name: project_id
  12. value: <REPLACE-WITH-PROJECT-ID> # Required.
  13. - name: private_key_id
  14. value: <REPLACE-WITH-PRIVATE-KEY-ID> # Required.
  15. - name: private_key
  16. value: <REPLACE-WITH-PRIVATE-KEY> # Required.
  17. - name: client_email
  18. value: <REPLACE-WITH-CLIENT-EMAIL> # Required.
  19. - name: client_id
  20. value: <REPLACE-WITH-CLIENT-ID> # Required.
  21. - name: auth_uri
  22. value: <REPLACE-WITH-AUTH-URI> # Required.
  23. - name: token_uri
  24. value: <REPLACE-WITH-TOKEN-URI> # Required.
  25. - name: auth_provider_x509_cert_url
  26. value: <REPLACE-WITH-AUTH-X509-CERT-URL> # Required.
  27. - name: client_x509_cert_url
  28. value: <REPLACE-WITH-CLIENT-x509-CERT-URL> # Required.
  29. - name: entity_kind
  30. value: <REPLACE-WITH-ENTITY-KIND> # Optional. default: "DaprState"

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
typeYThe credentials type“serviceaccount”
project_idYThe ID of the GCP project to use“project-id”
private_key_idYThe ID of the prvate key to use“private-key-id”
client_emailYThe email address for the client“eample@example.com”
client_idYThe client id value to use for authentication“client-id”
auth_uriYThe authentication URI to usehttps://accounts.google.com/o/oauth2/auth
token_uriYThe token URI to query for Auth tokenhttps://oauth2.googleapis.com/token
auth_provider_x509_cert_urlYThe auth provider certificate URLhttps://www.googleapis.com/oauth2/v1/certs
client_x509_cert_urlYThe client certificate URLhttps://www.googleapis.com/robot/v1/metadata/x509/x
entity_kindNThe entity name in Filestore. Defaults to “DaprState”“DaprState”

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 localhost:8081.

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

Last modified July 27, 2022: Remove namespace element from component examples (#2647) (ff9de5c8)