Search code examples
google-workflows

Trigger Google Workflow from document update in Firestore


When there is an update in my Cloud Firestore, I would like it to trigger a workflows that consumes the document id as a parameter.


Solution

  • You can leverage EventArc to have an event reported to Audit Logs be picked up by EventArc and used as trigger for your Workflow.

    Essentially the command is from this tutorial page:

    gcloud eventarc triggers create TRIGGER \
        --location=LOCATION \
        --destination-workflow=DESTINATION_WORKFLOW \
        --destination-workflow-location=DESTINATION_WORKFLOW_LOCATION \
        --event-filters="type=google.cloud.audit.log.v1.written" \
        --event-filters="serviceName=SERVICE_NAME" \
        --event-filters="methodName=METHOD_NAME" \
        --service-account="MY_SERVICE_ACCOUNT@PROJECT_ID.iam.gserviceaccount.com"
    

    where the event-filter

    • serviceName= firestore.googleapis.com
    • methodName=pick from a list

    the methodName options are described on this page.