> ## Documentation Index
> Fetch the complete documentation index at: https://docs.peerdb.io/llms.txt
> Use this file to discover all available pages before exploring further.

# PubSub Setup Guide

<Warning>
  Google Pub/Sub as a destination is deprecated and no longer actively maintained. It remains fully functional and no code is currently being removed. For new mirrors, we recommend ClickHouse, ClickHouse Cloud, or Postgres as the destination.
</Warning>

1. [Create a dedicated Service Account](https://cloud.google.com/iam/docs/keys-create-delete#iam-service-account-keys-create-console)
   for PeerDB through Google Cloud Console and specify the following roles:

* `Pub/Sub Viewer` : PeerDB requires this role to check if your provided topic exists.
* `Pub/Sub Publisher` : PeerDB requires this role to publish messages to the topic.

  <Frame caption="Create a dedicated Service Account For PeerDB and grant the necessary permissions">
    <img src="https://mintcdn.com/peerdb/L54DxDXK99_p-wL9/images/setup/pubsub-setup.png?fit=max&auto=format&n=L54DxDXK99_p-wL9&q=85&s=d35071b73f098398df077126fd99b93b" width="916" height="579" data-path="images/setup/pubsub-setup.png" />
  </Frame>

2. Add a key to the above created service account
   <Frame caption="Add Key to the Service Account">
     <img src="https://mintcdn.com/peerdb/L54DxDXK99_p-wL9/images/setup/bq-add-key-1.png?fit=max&auto=format&n=L54DxDXK99_p-wL9&q=85&s=848581b8fb9968cf2e0d7ad9e2a5d97e" width="2118" height="1490" data-path="images/setup/bq-add-key-1.png" />
   </Frame>
   <Frame caption="Key Added to the Service Account">
     <img src="https://mintcdn.com/peerdb/L54DxDXK99_p-wL9/images/setup/bq-add-key-2.png?fit=max&auto=format&n=L54DxDXK99_p-wL9&q=85&s=ab351ed15edb842642b172d8fa3ca31f" width="2080" height="1432" data-path="images/setup/bq-add-key-2.png" />
   </Frame>

3. Using this service account key create the peer using PeerDB UI

   <Frame caption="Create PubSub Peer">
     <img src="https://mintcdn.com/peerdb/L54DxDXK99_p-wL9/images/setup/pubsub-create-peer.png?fit=max&auto=format&n=L54DxDXK99_p-wL9&q=85&s=eff6d6f3c73810f56aa0257c2445f87f" width="1234" height="752" data-path="images/setup/pubsub-create-peer.png" />
   </Frame>

***

### Topic creation

By default, you would need to create the destination topic in PubSub before creating a mirror.
However, if you'd like PeerDB to create the topic for you, you can turn on the following setting in PeerDB UI:

<Frame caption="Add Key to the Service Account">
  <img src="https://mintcdn.com/peerdb/MRN5BST_xrBv7brJ/images/cdc_kafka/topiccreate.png?fit=max&auto=format&n=MRN5BST_xrBv7brJ&q=85&s=dac6b53da4cc089b7131b9a49296ea21" width="2132" height="636" data-path="images/cdc_kafka/topiccreate.png" />
</Frame>

Note that you must create a subscription on the topic for messages to be retained.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.