GCP Pub/Sub

Detailed documentation on the GCP Pub/Sub component

Setup GCP Pub/Sub

Follow the instructions here on setting up Google Cloud Pub/Sub system.

Create a Dapr component

The next step is to create a Dapr component for Google Cloud Pub/Sub

Create the following YAML file named messagebus.yaml:

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. namespace: <NAMESPACE>
  6. spec:
  7. type: pubsub.gcp.pubsub
  8. version: v1
  9. metadata:
  10. - name: topic
  11. value: <TOPIC_NAME>
  12. - name: type
  13. value: service_account
  14. - name: project_id
  15. value: <PROJECT_ID> # replace
  16. - name: private_key_id
  17. value: <PRIVATE_KEY_ID> #replace
  18. - name: client_email
  19. value: <CLIENT_EMAIL> #replace
  20. - name: client_id
  21. value: <CLIENT_ID> # replace
  22. - name: auth_uri
  23. value: https://accounts.google.com/o/oauth2/auth
  24. - name: token_uri
  25. value: https://oauth2.googleapis.com/token
  26. - name: auth_provider_x509_cert_url
  27. value: https://www.googleapis.com/oauth2/v1/certs
  28. - name: client_x509_cert_url
  29. value: https://www.googleapis.com/robot/v1/metadata/x509/<PROJECT_NAME>.iam.gserviceaccount.com
  30. - name: private_key
  31. value: <PRIVATE_KEY> # replace x509 cert here
  32. - name: disableEntityManagement
  33. value: <REPLACE-WITH-DISABLE-ENTITY-MANAGEMENT> # Optional. Default: false. When set to true, topics and subscriptions do not get created automatically.
  • topic is the Pub/Sub topic name.
  • type is the GCP credentials type.
  • project_id is the GCP project id.
  • private_key_id is the GCP private key id.
  • client_email is the GCP client email.
  • client_id is the GCP client id.
  • auth_uri is Google account OAuth endpoint.
  • token_uri is Google account token uri.
  • auth_provider_x509_cert_url is the GCP credentials cert url.
  • client_x509_cert_url is the GCP credentials project x509 cert url.
  • private_key is the GCP credentials private key.
  • disableEntityManagement Optional. Default: false. When set to true, topics and subscriptions do not get created automatically.

Warning

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

Apply the configuration

Visit this guide for instructions on configuring pub/sub components.

Related links

Last modified February 16, 2021: Merge pull request #1235 from dapr/update-v0.11 (b4e9fbb)