Use GCP Pub/Sub Realtime Trigger to push events into Firestore

About this blueprint

GCP Queue Realtime

This flow will:

  1. Get triggered every time the event lands in the Pub/Sub topic
  2. The flow will push the data into Firestore table

For this, create a Pub/Sub topic named orders. We will be producing JSON messages into the Pub/Sub topic generated from the orders.csv. One sample produced message can be:

{"order_id": "1", "customer_name": "Kelly Olsen", "customer_email": "[email protected]", "product_id": "20", "price": "166.89", "quantity": "1", "total": "166.89"}

Create orders table in Firestore.

When you produce the message onto Pub/Sub topic, the flow will get triggered, and you can see that a corresponding new record gets into the Firestore table.

id: pubsub_realtime_trigger

  - id: insert_into_firestore
    type: io.kestra.plugin.gcp.firestore.Set
    projectId: test-project-id
    collection: orders
      order_id: "{{ | jq('.order_id') | first }}" 
      customer_name: "{{ | jq('.customer_name') | first }}"    
      customer_email: "{{ | jq('.customer_email') | first }}"
      product_id: "{{ | jq('.product_id') | first }}"
      price: "{{ | jq('.price') | first }}"
      quantity: "{{ | jq('.quantity') | first }}"
      total: "{{ | jq('.total') | first }}"
  - id: realtime_trigger
    type: io.kestra.plugin.gcp.pubsub.RealtimeTrigger
    projectId: test-project-id
    topic: orders
    subscription: kestra-subscription
    serdeType: JSON


Realtime Trigger

New to Kestra?

Use blueprints to kickstart your first workflows.

Get started with Kestra