Blueprints

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

About this blueprint

GCP Queue Realtime Trigger Trigger

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.

yaml
id: pubsub_realtime_trigger
namespace: company.team

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

Set

Realtime Trigger

New to Kestra?

Use blueprints to kickstart your first workflows.

Get started with Kestra